import React, { Fragment, PureComponent } from 'react'
import { message } from 'antd';

class Qrdecoder extends PureComponent {

    componentDidMount() {
        setTimeout(() => {

            var _aa = {};
            _aa._ab = function (f, e) {
                var d = qrcode.width; var b = qrcode.height; var c = true;
                for (var g = 0; g < e.length && c; g += 2) {
                    var a = Math.floor(e[g]); var h = Math.floor(e[g + 1]); if (a < -1 || a > d || h < -1 || h > b) { throw "Error._ab " } c = false; if (a == -1) { e[g] = 0; c = true } else { if (a == d) { e[g] = d - 1; c = true } } if (h == -1) { e[g + 1] = 0; c = true } else { if (h == b) { e[g + 1] = b - 1; c = true } }
                } c = true;
                for (var g = e.length - 2; g >= 0 && c; g -= 2) {
                    var a = Math.floor(e[g]); var h = Math.floor(e[g + 1]); if (a < -1 || a > d || h < -1 || h > b) { throw "Error._ab " } c = false; if (a == -1) { e[g] = 0; c = true } else { if (a == d) { e[g] = d - 1; c = true } } if (h == -1) { e[g + 1] = 0; c = true } else { if (h == b) { e[g + 1] = b - 1; c = true } }
                }
            };
            _aa._af = function (b, d, a) { var k = new _ac(d); var j = new Array(d << 1); for (var f = 0; f < d; f++) { var g = j.length; var i = f + 0.5; for (var h = 0; h < g; h += 2) { j[h] = (h >> 1) + 0.5; j[h + 1] = i } a._ad(j); _aa._ab(b, j); try { for (var h = 0; h < g; h += 2) { var e = b[Math.floor(j[h]) + qrcode.width * Math.floor(j[h + 1])]; if (e) { k._dq(h >> 1, f) } } } catch (c) { throw "Error._ab" } } return k }; _aa._ah = function (h, o, l, k, q, p, b, a, f, e, n, m, s, r, d, c, j, i) { var g = _ae._ag(l, k, q, p, b, a, f, e, n, m, s, r, d, c, j, i); return _aa._af(h, o, g) }; function _a1(b, a) { this.count = b; this._fc = a; this.__defineGetter__("Count", function () { return this.count }); this.__defineGetter__("_dm", function () { return this._fc }) } function _a2(a, c, b) { this._bm = a; if (b) { this._do = new Array(c, b) } else { this._do = new Array(c) } this.__defineGetter__("_bo", function () { return this._bm }); this.__defineGetter__("_dn", function () { return this._bm * this._fo }); this.__defineGetter__("_fo", function () { var e = 0; for (var d = 0; d < this._do.length; d++) { e += this._do[d].length } return e }); this._fb = function () { return this._do } } function _a3(k, l, h, g, f, e) { this._bs = k; this._ar = l; this._do = new Array(h, g, f, e); var j = 0; var b = h._bo; var a = h._fb(); for (var d = 0; d < a.length; d++) { var c = a[d]; j += c.Count * (c._dm + b) } this._br = j; this.__defineGetter__("_fd", function () { return this._bs }); this.__defineGetter__("_as", function () { return this._ar }); this.__defineGetter__("_dp", function () { return this._br }); this.__defineGetter__("_cr", function () { return 17 + 4 * this._bs }); this._aq = function () { var q = this._cr; var o = new _ac(q); o._bq(0, 0, 9, 9); o._bq(q - 8, 0, 8, 9); o._bq(0, q - 8, 9, 8); var n = this._ar.length; for (var m = 0; m < n; m++) { var p = this._ar[m] - 2; for (var r = 0; r < n; r++) { if ((m == 0 && (r == 0 || r == n - 1)) || (m == n - 1 && r == 0)) { continue } o._bq(this._ar[r] - 2, p, 5, 5) } } o._bq(6, 9, 1, q - 17); o._bq(9, 6, q - 17, 1); if (this._bs > 6) { o._bq(q - 11, 0, 3, 6); o._bq(0, q - 11, 6, 3) } return o }; this._bu = function (i) { return this._do[i.ordinal()] } } _a3._bv = new Array(31892, 34236, 39577, 42195, 48118, 51042, 55367, 58893, 63784, 68472, 70749, 76311, 79154, 84390, 87683, 92361, 96236, 102084, 102881, 110507, 110734, 117786, 119615, 126325, 127568, 133589, 136944, 141498, 145311, 150283, 152622, 158308, 161089, 167017); _a3.VERSIONS = _ay(); _a3._av = function (a) { if (a < 1 || a > 40) { throw "bad arguments" } return _a3.VERSIONS[a - 1] }; _a3._at = function (b) { if (b % 4 != 1) { throw "Error _at" } try { return _a3._av((b - 17) >> 2) } catch (a) { throw "Error _av" } }; _a3._aw = function (d) { var b = 4294967295; var f = 0; for (var c = 0; c < _a3._bv.length; c++) { var a = _a3._bv[c]; if (a == d) { return this._av(c + 7) } var e = _ax._gj(d, a); if (e < b) { f = c + 7; b = e } } if (b <= 3) { return this._av(f) } return null }; function _ay() {
                return new Array(new _a3(1, new Array(), new _a2(7, new _a1(1, 19)), new _a2(10, new _a1(1, 16)), new _a2(13, new _a1(1, 13)), new _a2(17, new _a1(1, 9))), new _a3(2, new Array(6, 18), new _a2(10, new _a1(1, 34)), new _a2(16, new _a1(1, 28)), new _a2(22, new _a1(1, 22)), new _a2(28, new _a1(1, 16))), new _a3(3, new Array(6, 22), new _a2(15, new _a1(1, 55)), new _a2(26, new _a1(1, 44)), new _a2(18, new _a1(2, 17)), new _a2(22, new _a1(2, 13))), new _a3(4, new Array(6, 26), new _a2(20, new _a1(1, 80)), new _a2(18, new _a1(2, 32)), new _a2(26, new _a1(2, 24)), new _a2(16, new _a1(4, 9))), new _a3(5, new Array(6, 30), new _a2(26, new _a1(1, 108)), new _a2(24, new _a1(2, 43)), new _a2(18, new _a1(2, 15), new _a1(2, 16)), new _a2(22, new _a1(2, 11), new _a1(2, 12))), new _a3(6, new Array(6, 34), new _a2(18, new _a1(2, 68)), new _a2(16, new _a1(4, 27)), new _a2(24, new _a1(4, 19)), new _a2(28, new _a1(4, 15))), new _a3(7, new Array(6, 22, 38), new _a2(20, new _a1(2, 78)), new _a2(18, new _a1(4, 31)), new _a2(18, new _a1(2, 14), new _a1(4, 15)), new _a2(26, new _a1(4, 13), new _a1(1, 14))), new _a3(8, new Array(6, 24, 42), new _a2(24, new _a1(2, 97)), new _a2(22, new _a1(2, 38), new _a1(2, 39)), new _a2(22, new _a1(4, 18), new _a1(2, 19)), new _a2(26, new _a1(4, 14), new _a1(2, 15))), new _a3(9, new Array(6, 26, 46), new _a2(30, new _a1(2, 116)), new _a2(22, new _a1(3, 36), new _a1(2, 37)), new _a2(20, new _a1(4, 16), new _a1(4, 17)), new _a2(24, new _a1(4, 12), new _a1(4, 13))), new _a3(10, new Array(6, 28, 50), new _a2(18, new _a1(2, 68), new _a1(2, 69)), new _a2(26, new _a1(4, 43), new _a1(1, 44)), new _a2(24, new _a1(6, 19), new _a1(2, 20)), new _a2(28, new _a1(6, 15), new _a1(2, 16))), new _a3(11, new Array(6, 30, 54), new _a2(20, new _a1(4, 81)), new _a2(30, new _a1(1, 50), new _a1(4, 51)), new _a2(28, new _a1(4, 22), new _a1(4, 23)), new _a2(24, new _a1(3, 12), new _a1(8, 13))), new _a3(12, new Array(6, 32, 58), new _a2(24, new _a1(2, 92), new _a1(2, 93)), new _a2(22, new _a1(6, 36), new _a1(2, 37)), new _a2(26, new _a1(4, 20), new _a1(6, 21)), new _a2(28, new _a1(7, 14), new _a1(4, 15))), new _a3(13, new Array(6, 34, 62), new _a2(26, new _a1(4, 107)), new _a2(22, new _a1(8, 37), new _a1(1, 38)), new _a2(24, new _a1(8, 20), new _a1(4, 21)), new _a2(22, new _a1(12, 11), new _a1(4, 12))), new _a3(14, new Array(6, 26, 46, 66)
                    , new _a2(30, new _a1(3, 115), new _a1(1, 116)), new _a2(24, new _a1(4, 40), new _a1(5, 41)), new _a2(20, new _a1(11, 16), new _a1(5, 17)), new _a2(24, new _a1(11, 12), new _a1(5, 13))), new _a3(15, new Array(6, 26, 48, 70), new _a2(22, new _a1(5, 87), new _a1(1, 88)), new _a2(24, new _a1(5, 41), new _a1(5, 42)), new _a2(30, new _a1(5, 24), new _a1(7, 25)), new _a2(24, new _a1(11, 12), new _a1(7, 13))), new _a3(16, new Array(6, 26, 50, 74), new _a2(24, new _a1(5, 98), new _a1(1, 99)), new _a2(28, new _a1(7, 45), new _a1(3, 46)), new _a2(24, new _a1(15, 19), new _a1(2, 20)), new _a2(30, new _a1(3, 15), new _a1(13, 16))), new _a3(17, new Array(6, 30, 54, 78), new _a2(28, new _a1(1, 107), new _a1(5, 108)), new _a2(28, new _a1(10, 46), new _a1(1, 47)), new _a2(28, new _a1(1, 22), new _a1(15, 23)), new _a2(28, new _a1(2, 14), new _a1(17, 15))), new _a3(18, new Array(6, 30, 56, 82), new _a2(30, new _a1(5, 120), new _a1(1, 121)), new _a2(26, new _a1(9, 43), new _a1(4, 44)), new _a2(28, new _a1(17, 22), new _a1(1, 23)), new _a2(28, new _a1(2, 14), new _a1(19, 15))), new _a3(19, new Array(6, 30, 58, 86), new _a2(28, new _a1(3, 113), new _a1(4, 114)), new _a2(26, new _a1(3, 44), new _a1(11, 45)), new _a2(26, new _a1(17, 21), new _a1(4, 22)), new _a2(26, new _a1(9, 13), new _a1(16, 14))), new _a3(20, new Array(6, 34, 62, 90), new _a2(28, new _a1(3, 107), new _a1(5, 108)), new _a2(26, new _a1(3, 41), new _a1(13, 42)), new _a2(30, new _a1(15, 24), new _a1(5, 25)), new _a2(28, new _a1(15, 15), new _a1(10, 16))), new _a3(21, new Array(6, 28, 50, 72, 94), new _a2(28, new _a1(4, 116), new _a1(4, 117)), new _a2(26, new _a1(17, 42)), new _a2(28, new _a1(17, 22), new _a1(6, 23)), new _a2(30, new _a1(19, 16), new _a1(6, 17))), new _a3(22, new Array(6, 26, 50, 74, 98), new _a2(28, new _a1(2, 111), new _a1(7, 112)), new _a2(28, new _a1(17, 46)), new _a2(30, new _a1(7, 24), new _a1(16, 25)), new _a2(24, new _a1(34, 13))), new _a3(23, new Array(6, 30, 54, 78, 102), new _a2(30, new _a1(4, 121), new _a1(5, 122)), new _a2(28, new _a1(4, 47), new _a1(14, 48)), new _a2(30, new _a1(11, 24), new _a1(14, 25)), new _a2(30, new _a1(16, 15), new _a1(14, 16))), new _a3(24, new Array(6, 28, 54, 80, 106), new _a2(30, new _a1(6, 117), new _a1(4, 118)), new _a2(28, new _a1(6, 45), new _a1(14, 46)), new _a2(30, new _a1(11, 24), new _a1(16, 25)), new _a2(30, new _a1(30, 16), new _a1(2, 17))), new _a3(25, new Array(6, 32, 58, 84, 110), new _a2(26, new _a1(8, 106), new _a1(4, 107)), new _a2(28, new _a1(8, 47), new _a1(13, 48)), new _a2(30, new _a1(7, 24), new _a1(22, 25)), new _a2(30, new _a1(22, 15), new _a1(13, 16))), new _a3(26, new Array(6, 30, 58, 86, 114), new _a2(28, new _a1(10, 114), new _a1(2, 115)), new _a2(28, new _a1(19, 46), new _a1(4, 47)), new _a2(28, new _a1(28, 22), new _a1(6, 23)), new _a2(30, new _a1(33, 16), new _a1(4, 17))), new _a3(27, new Array(6, 34, 62, 90, 118), new _a2(30, new _a1(8, 122), new _a1(4, 123)), new _a2(28, new _a1(22, 45), new _a1(3, 46)), new _a2(30, new _a1(8, 23), new _a1(26, 24)), new _a2(30, new _a1(12, 15), new _a1(28, 16))), new _a3(28, new Array(6, 26, 50, 74, 98, 122), new _a2(30, new _a1(3, 117), new _a1(10, 118)), new _a2(28, new _a1(3, 45), new _a1(23, 46)), new _a2(30, new _a1(4, 24), new _a1(31, 25)), new _a2(30, new _a1(11, 15), new _a1(31, 16))), new _a3(29, new Array(6, 30, 54, 78, 102, 126), new _a2(30, new _a1(7, 116), new _a1(7, 117)), new _a2(28, new _a1(21, 45), new _a1(7, 46)),
                        new _a2(30, new _a1(1, 23), new _a1(37, 24)), new _a2(30, new _a1(19, 15), new _a1(26, 16))), new _a3(30, new Array(6, 26, 52, 78, 104, 130), new _a2(30, new _a1(5, 115), new _a1(10, 116)), new _a2(28, new _a1(19, 47), new _a1(10, 48)), new _a2(30, new _a1(15, 24), new _a1(25, 25)), new _a2(30, new _a1(23, 15), new _a1(25, 16))), new _a3(31, new Array(6, 30, 56, 82, 108, 134), new _a2(30, new _a1(13, 115), new _a1(3, 116)), new _a2(28, new _a1(2, 46), new _a1(29, 47)), new _a2(30, new _a1(42, 24), new _a1(1, 25)), new _a2(30, new _a1(23, 15), new _a1(28, 16))), new _a3(32, new Array(6, 34, 60, 86, 112, 138), new _a2(30, new _a1(17, 115)), new _a2(28, new _a1(10, 46), new _a1(23, 47)), new _a2(30, new _a1(10, 24), new _a1(35, 25)), new _a2(30, new _a1(19, 15), new _a1(35, 16))), new _a3(33, new Array(6, 30, 58, 86, 114, 142), new _a2(30, new _a1(17, 115), new _a1(1, 116)), new _a2(28, new _a1(14, 46), new _a1(21, 47)), new _a2(30, new _a1(29, 24), new _a1(19, 25)), new _a2(30, new _a1(11, 15), new _a1(46, 16))), new _a3(34, new Array(6, 34, 62, 90, 118, 146), new _a2(30, new _a1(13, 115), new _a1(6, 116)), new _a2(28, new _a1(14, 46), new _a1(23, 47)), new _a2(30, new _a1(44, 24), new _a1(7, 25)), new _a2(30, new _a1(59, 16), new _a1(1, 17))), new _a3(35, new Array(6, 30, 54, 78, 102, 126, 150), new _a2(30, new _a1(12, 121), new _a1(7, 122)), new _a2(28, new _a1(12, 47), new _a1(26, 48)), new _a2(30, new _a1(39, 24), new _a1(14, 25)), new _a2(30, new _a1(22, 15), new _a1(41, 16))), new _a3(36, new Array(6, 24, 50, 76, 102, 128, 154), new _a2(30, new _a1(6, 121), new _a1(14, 122)), new _a2(28, new _a1(6, 47), new _a1(34, 48)), new _a2(30, new _a1(46, 24), new _a1(10, 25)), new _a2(30, new _a1(2, 15), new _a1(64, 16))), new _a3(37, new Array(6, 28, 54, 80, 106, 132, 158), new _a2(30, new _a1(17, 122), new _a1(4, 123)), new _a2(28, new _a1(29, 46), new _a1(14, 47)), new _a2(30, new _a1(49, 24), new _a1(10, 25)), new _a2(30, new _a1(24, 15), new _a1(46, 16))), new _a3(38, new Array(6, 32, 58, 84, 110, 136, 162), new _a2(30, new _a1(4, 122), new _a1(18, 123)), new _a2(28, new _a1(13, 46), new _a1(32, 47)), new _a2(30, new _a1(48, 24), new _a1(14, 25)), new _a2(30, new _a1(42, 15), new _a1(32, 16))), new _a3(39, new Array(6, 26, 54, 82, 110, 138, 166), new _a2(30, new _a1(20, 117), new _a1(4, 118)), new _a2(28, new _a1(40, 47), new _a1(7, 48)), new _a2(30, new _a1(43, 24), new _a1(22, 25)), new _a2(30, new _a1(10, 15), new _a1(67, 16))), new _a3(40, new Array(6, 30, 58, 86, 114, 142, 170), new _a2(30, new _a1(19, 118), new _a1(6, 119)), new _a2(28, new _a1(18, 47), new _a1(31, 48)), new _a2(30, new _a1(34, 24), new _a1(34, 25)), new _a2(30, new _a1(20, 15), new _a1(61, 16))))
            }
            function _ae(i, f, c, h, e, b, g, d, a) { this.a11 = i; this.a12 = h; this.a13 = g; this.a21 = f; this.a22 = e; this.a23 = d; this.a31 = c; this.a32 = b; this.a33 = a; this._ad = function (v) { var s = v.length; var z = this.a11; var w = this.a12; var u = this.a13; var q = this.a21; var p = this.a22; var o = this.a23; var m = this.a31; var k = this.a32; var j = this.a33; for (var n = 0; n < s; n += 2) { var t = v[n]; var r = v[n + 1]; var l = u * t + o * r + j; v[n] = (z * t + q * r + m) / l; v[n + 1] = (w * t + p * r + k) / l } }; this._fp = function (m, k) { var q = m.length; for (var l = 0; l < q; l++) { var j = m[l]; var p = k[l]; var o = this.a13 * j + this.a23 * p + this.a33; m[l] = (this.a11 * j + this.a21 * p + this.a31) / o; k[l] = (this.a12 * j + this.a22 * p + this.a32) / o } }; this._fr = function () { return new _ae(this.a22 * this.a33 - this.a23 * this.a32, this.a23 * this.a31 - this.a21 * this.a33, this.a21 * this.a32 - this.a22 * this.a31, this.a13 * this.a32 - this.a12 * this.a33, this.a11 * this.a33 - this.a13 * this.a31, this.a12 * this.a31 - this.a11 * this.a32, this.a12 * this.a23 - this.a13 * this.a22, this.a13 * this.a21 - this.a11 * this.a23, this.a11 * this.a22 - this.a12 * this.a21) }; this.times = function (j) { return new _ae(this.a11 * j.a11 + this.a21 * j.a12 + this.a31 * j.a13, this.a11 * j.a21 + this.a21 * j.a22 + this.a31 * j.a23, this.a11 * j.a31 + this.a21 * j.a32 + this.a31 * j.a33, this.a12 * j.a11 + this.a22 * j.a12 + this.a32 * j.a13, this.a12 * j.a21 + this.a22 * j.a22 + this.a32 * j.a23, this.a12 * j.a31 + this.a22 * j.a32 + this.a32 * j.a33, this.a13 * j.a11 + this.a23 * j.a12 + this.a33 * j.a13, this.a13 * j.a21 + this.a23 * j.a22 + this.a33 * j.a23, this.a13 * j.a31 + this.a23 * j.a32 + this.a33 * j.a33) } } _ae._ag = function (p, e, o, d, n, c, m, b, h, q, l, f, a, j, i, r) { var g = this._be(p, e, o, d, n, c, m, b); var k = this._bf(h, q, l, f, a, j, i, r); return k.times(g) }; _ae._bf = function (d, p, c, m, b, k, a, j) {
                var h = j - k; var f = p - m + k - j; if (h == 0 && f == 0) { return new _ae(c - d, b - c, d, m - p, k - m, p, 0, 0, 1) } else {
                    var q = c - b; var o = a - b;
                    var l = d - c + b - a; var i = m - k; var e = q * h - o * i; var n = (l * h - o * f) / e; var g = (q * f - l * i) / e; return new _ae(c - d + n * c, a - d + g * a, d, m - p + n * m, j - p + g * j, p, n, g, 1)
                }
            };
            _ae._be = function (f, h, d, g, b, e, a, c) { return this._bf(f, h, d, g, b, e, a, c)._fr() }; function _bg(b, a) { this.bits = b; this.points = a } function Detector(a) {
                this.image = a; this._am = null; this._bi = function (m, l, c, b) { var d = Math.abs(b - l) > Math.abs(c - m); if (d) { var r = m; m = l; l = r; r = c; c = b; b = r } var j = Math.abs(c - m); var i = Math.abs(b - l); var p = -j >> 1; var u = l < b ? 1 : -1; var f = m < c ? 1 : -1; var e = 0; for (var h = m, g = l; h != c; h += f) { var t = d ? g : h; var s = d ? h : g; if (e == 1) { if (this.image[t + s * qrcode.width]) { e++ } } else { if (!this.image[t + s * qrcode.width]) { e++ } } if (e == 3) { var o = h - m; var n = g - l; return Math.sqrt((o * o + n * n)) } p += i; if (p > 0) { if (g == b) { break } g += u; p -= j } } var k = c - m; var q = b - l; return Math.sqrt((k * k + q * q)) }; this._bh = function (i, g, h, f) { var b = this._bi(i, g, h, f); var e = 1; var d = i - (h - i); if (d < 0) { e = i / (i - d); d = 0 } else { if (d >= qrcode.width) { e = (qrcode.width - 1 - i) / (d - i); d = qrcode.width - 1 } } var c = Math.floor(g - (f - g) * e); e = 1; if (c < 0) { e = g / (g - c); c = 0 } else { if (c >= qrcode.height) { e = (qrcode.height - 1 - g) / (c - g); c = qrcode.height - 1 } } d = Math.floor(i + (d - i) * e); b += this._bi(i, g, d, c); return b - 1 }; this._bj = function (c, d) { var b = this._bh(Math.floor(c.X), Math.floor(c.Y), Math.floor(d.X), Math.floor(d.Y)); var e = this._bh(Math.floor(d.X), Math.floor(d.Y), Math.floor(c.X), Math.floor(c.Y)); if (isNaN(b)) { return e / 7 } if (isNaN(e)) { return b / 7 } return (b + e) / 14 }; this._bk = function (d, c, b) { return (this._bj(d, c) + this._bj(d, b)) / 2 }; this.distance = function (d, b) { var e = d.X - b.X; var c = d.Y - b.Y; return Math.sqrt((e * e + c * c)) }; this._bx = function (g, f, d, e) { var b = Math.round(this.distance(g, f) / e); var c = Math.round(this.distance(g, d) / e); var h = ((b + c) >> 1) + 7; switch (h & 3) { case 0: h++; break; case 2: h--; break; case 3: throw "Error" }return h }; this._bl = function (g, f, d, j) { var k = Math.floor(j * g); var h = Math.max(0, f - k); var i = Math.min(qrcode.width - 1, f + k); if (i - h < g * 3) { throw "Error" } var b = Math.max(0, d - k); var c = Math.min(qrcode.height - 1, d + k); var e = new _ak(this.image, h, b, i - h, c - b, g, this._am); return e.find() }; this.createTransform = function (l, h, k, b, g) {
                    var j = g - 3.5; var i; var f; var e; var c;
                    if (b != null) { i = b.X; f = b.Y; e = c = j - 3 } else { i = (h.X - l.X) + k.X; f = (h.Y - l.Y) + k.Y; e = c = j } var d = _ae._ag(3.5, 3.5, j, 3.5, e, c, 3.5, j, l.X, l.Y, h.X, h.Y, i, f, k.X, k.Y); return d
                }; this._bz = function (e, b, d) { var c = _aa; return c._af(e, d, b) }; this._cd = function (q) { var j = q._gq; var h = q._gs; var n = q._gp; var d = this._bk(j, h, n); if (d < 1) { throw "Error" } var r = this._bx(j, h, n, d); var b = _a3._at(r); var k = b._cr - 7; var l = null; if (b._as.length > 0) { var f = h.X - j.X + n.X; var e = h.Y - j.Y + n.Y; var c = 1 - 3 / k; var t = Math.floor(j.X + c * (f - j.X)); var s = Math.floor(j.Y + c * (e - j.Y)); for (var p = 4; p <= 16; p <<= 1) { l = this._bl(d, t, s, p); break } } var g = this.createTransform(j, h, n, l, r); var m = this._bz(this.image, g, r); var o; if (l == null) { o = new Array(n, j, h) } else { o = new Array(n, j, h, l) } return new _bg(m, o) }; this.detect = function () { var b = new _cc()._ce(this.image); return this._cd(b) }
            }
            var _ca = 21522; var _cb = new Array(new Array(21522, 0), new Array(20773, 1), new Array(24188, 2), new Array(23371, 3), new Array(17913, 4), new Array(16590, 5), new Array(20375, 6), new Array(19104, 7), new Array(30660, 8), new Array(29427, 9), new Array(32170, 10), new Array(30877, 11), new Array(26159, 12), new Array(25368, 13), new Array(27713, 14), new Array(26998, 15), new Array(5769, 16), new Array(5054, 17), new Array(7399, 18), new Array(6608, 19), new Array(1890, 20), new Array(597, 21), new Array(3340, 22), new Array(2107, 23), new Array(13663, 24), new Array(12392, 25), new Array(16177, 26), new Array(14854, 27), new Array(9396, 28), new Array(8579, 29), new Array(11994, 30), new Array(11245, 31)); var _ch = new Array(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4); function _ax(a) { this._cf = _cg.forBits((a >> 3) & 3); this._fe = (a & 7); this.__defineGetter__("_cg", function () { return this._cf }); this.__defineGetter__("_dx", function () { return this._fe }); this.GetHashCode = function () { return (this._cf.ordinal() << 3) | this._fe }; this.Equals = function (c) { var b = c; return this._cf == b._cf && this._fe == b._fe } } _ax._gj = function (d, c) { d ^= c; return _ch[d & 15] + _ch[(_ew(d, 4) & 15)] + _ch[(_ew(d, 8) & 15)] + _ch[(_ew(d, 12) & 15)] + _ch[(_ew(d, 16) & 15)] + _ch[(_ew(d, 20) & 15)] + _ch[(_ew(d, 24) & 15)] + _ch[(_ew(d, 28) & 15)] }; _ax._ci = function (a) { var b = _ax._cj(a); if (b != null) { return b } return _ax._cj(a ^ _ca) }; _ax._cj = function (d) { var b = 4294967295; var a = 0; for (var c = 0; c < _cb.length; c++) { var g = _cb[c]; var f = g[0]; if (f == d) { return new _ax(g[1]) } var e = this._gj(d, f); if (e < b) { a = g[1]; b = e } } if (b <= 3) { return new _ax(a) } return null }; function _cg(a, c, b) { this._ff = a; this.bits = c; this.name = b; this.__defineGetter__("Bits", function () { return this.bits }); this.__defineGetter__("Name", function () { return this.name }); this.ordinal = function () { return this._ff } } _cg.forBits = function (a) { if (a < 0 || a >= FOR_BITS.length) { throw "bad arguments" } return FOR_BITS[a] }; var L = new _cg(0, 1, "L"); var M = new _cg(1, 0, "M"); var Q = new _cg(2, 3, "Q"); var H = new _cg(3, 2, "H"); var FOR_BITS = new Array(M, L, H, Q); function _ac(d, a) {
                if (!a) { a = d } if (d < 1 || a < 1) { throw "Both dimensions must be greater than 0" } this.width = d; this.height = a; var c = d >> 5; if ((d & 31) != 0) { c++ } this.rowSize = c; this.bits = new Array(c * a); for (var b = 0; b < this.bits.length; b++) { this.bits[b] = 0 } this.__defineGetter__("Width", function () { return this.width }); this.__defineGetter__("Height", function () { return this.height });

                this.__defineGetter__("Dimension", function () { if (this.width != this.height) { throw "Can't call getDimension() on a non-square matrix" } return this.width }); this._ds = function (e, g) { var f = g * this.rowSize + (e >> 5); return ((_ew(this.bits[f], (e & 31))) & 1) != 0 }; this._dq = function (e, g) { var f = g * this.rowSize + (e >> 5); this.bits[f] |= 1 << (e & 31) }; this.flip = function (e, g) { var f = g * this.rowSize + (e >> 5); this.bits[f] ^= 1 << (e & 31) }; this.clear = function () { var e = this.bits.length; for (var f = 0; f < e; f++) { this.bits[f] = 0 } }; this._bq = function (g, j, f, m) { if (j < 0 || g < 0) { throw "Left and top must be nonnegative" } if (m < 1 || f < 1) { throw "Height and width must be at least 1" } var l = g + f; var e = j + m; if (e > this.height || l > this.width) { throw "The region must fit inside the matrix" } for (var i = j; i < e; i++) { var h = i * this.rowSize; for (var k = g; k < l; k++) { this.bits[h + (k >> 5)] |= 1 << (k & 31) } } }
            }
            function _dl(a, b) { this._dv = a; this._dw = b; this.__defineGetter__("_du", function () { return this._dv }); this.__defineGetter__("Codewords", function () { return this._dw }) } _dl._gn = function (c, h, r) { if (c.length != h._dp) { throw "bad arguments" } var k = h._bu(r); var e = 0; var d = k._fb(); for (var q = 0; q < d.length; q++) { e += d[q].Count } var l = new Array(e); var n = 0; for (var o = 0; o < d.length; o++) { var f = d[o]; for (var q = 0; q < f.Count; q++) { var m = f._dm; var s = k._bo + m; l[n++] = new _dl(m, new Array(s)) } } var t = l[0]._dw.length; var b = l.length - 1; while (b >= 0) { var v = l[b]._dw.length; if (v == t) { break } b-- } b++; var g = t - k._bo; var a = 0; for (var q = 0; q < g; q++) { for (var o = 0; o < n; o++) { l[o]._dw[q] = c[a++] } } for (var o = b; o < n; o++) { l[o]._dw[g] = c[a++] } var p = l[0]._dw.length; for (var q = g; q < p; q++) { for (var o = 0; o < n; o++) { var u = o < b ? q : q + 1; l[o]._dw[u] = c[a++] } } return l }; function _cl(a) { var b = a.Dimension; if (b < 21 || (b & 3) != 1) { throw "Error _cl" } this._au = a; this._cp = null; this._co = null; this._dk = function (d, c, e) { return this._au._ds(d, c) ? (e << 1) | 1 : e << 1 }; this._cm = function () { if (this._co != null) { return this._co } var g = 0; for (var e = 0; e < 6; e++) { g = this._dk(e, 8, g) } g = this._dk(7, 8, g); g = this._dk(8, 8, g); g = this._dk(8, 7, g); for (var c = 5; c >= 0; c--) { g = this._dk(8, c, g) } this._co = _ax._ci(g); if (this._co != null) { return this._co } var f = this._au.Dimension; g = 0; var d = f - 8; for (var e = f - 1; e >= d; e--) { g = this._dk(e, 8, g) } for (var c = f - 7; c < f; c++) { g = this._dk(8, c, g) } this._co = _ax._ci(g); if (this._co != null) { return this._co } throw "Error _cm" }; this._cq = function () { if (this._cp != null) { return this._cp } var h = this._au.Dimension; var f = (h - 17) >> 2; if (f <= 6) { return _a3._av(f) } var g = 0; var e = h - 11; for (var c = 5; c >= 0; c--) { for (var d = h - 9; d >= e; d--) { g = this._dk(d, c, g) } } this._cp = _a3._aw(g); if (this._cp != null && this._cp._cr == h) { return this._cp } g = 0; for (var d = 5; d >= 0; d--) { for (var c = h - 9; c >= e; c--) { g = this._dk(d, c, g) } } this._cp = _a3._aw(g); if (this._cp != null && this._cp._cr == h) { return this._cp } throw "Error _cq" }; this._gk = function () { var q = this._cm(); var o = this._cq(); var c = _dx._gl(q._dx); var f = this._au.Dimension; c._dj(this._au, f); var k = o._aq(); var n = true; var r = new Array(o._dp); var m = 0; var p = 0; var h = 0; for (var e = f - 1; e > 0; e -= 2) { if (e == 6) { e-- } for (var l = 0; l < f; l++) { var g = n ? f - 1 - l : l; for (var d = 0; d < 2; d++) { if (!k._ds(e - d, g)) { h++; p <<= 1; if (this._au._ds(e - d, g)) { p |= 1 } if (h == 8) { r[m++] = p; h = 0; p = 0 } } } } n ^= true } if (m != o._dp) { throw "Error _gk" } return r } } var _dx = {}; _dx._gl = function (a) { if (a < 0 || a > 7) { throw "bad arguments" } return _dx._dy[a] }; function _fg() { this._dj = function (c, d) { for (var b = 0; b < d; b++) { for (var a = 0; a < d; a++) { if (this._fw(b, a)) { c.flip(a, b) } } } }; this._fw = function (b, a) { return ((b + a) & 1) == 0 } } function _fh() { this._dj = function (c, d) { for (var b = 0; b < d; b++) { for (var a = 0; a < d; a++) { if (this._fw(b, a)) { c.flip(a, b) } } } }; this._fw = function (b, a) { return (b & 1) == 0 } } function _fi() { this._dj = function (c, d) { for (var b = 0; b < d; b++) { for (var a = 0; a < d; a++) { if (this._fw(b, a)) { c.flip(a, b) } } } }; this._fw = function (b, a) { return a % 3 == 0 } } function _fj() { this._dj = function (c, d) { for (var b = 0; b < d; b++) { for (var a = 0; a < d; a++) { if (this._fw(b, a)) { c.flip(a, b) } } } }; this._fw = function (b, a) { return (b + a) % 3 == 0 } } function _fk() { this._dj = function (c, d) { for (var b = 0; b < d; b++) { for (var a = 0; a < d; a++) { if (this._fw(b, a)) { c.flip(a, b) } } } }; this._fw = function (b, a) { return (((_ew(b, 1)) + (a / 3)) & 1) == 0 } } function _fl() { this._dj = function (c, d) { for (var b = 0; b < d; b++) { for (var a = 0; a < d; a++) { if (this._fw(b, a)) { c.flip(a, b) } } } }; this._fw = function (c, b) { var a = c * b; return (a & 1) + (a % 3) == 0 } } function _fm() { this._dj = function (c, d) { for (var b = 0; b < d; b++) { for (var a = 0; a < d; a++) { if (this._fw(b, a)) { c.flip(a, b) } } } }; this._fw = function (c, b) { var a = c * b; return (((a & 1) + (a % 3)) & 1) == 0 } } function _fn() { this._dj = function (c, d) { for (var b = 0; b < d; b++) { for (var a = 0; a < d; a++) { if (this._fw(b, a)) { c.flip(a, b) } } } }; this._fw = function (b, a) { return ((((b + a) & 1) + ((b * a) % 3)) & 1) == 0 } } _dx._dy = new Array(new _fg(), new _fh(), new _fi(), new _fj(), new _fk(), new _fl(), new _fm(), new _fn()); function _db(a) {
                this._fa = a; this.decode = function (j, f) { var c = new _bp(this._fa, j); var p = new Array(f); for (var g = 0; g < p.length; g++) { p[g] = 0 } var m = false; var d = true; for (var g = 0; g < f; g++) { var q = c.evaluateAt(this._fa.exp(m ? g + 1 : g)); p[p.length - 1 - g] = q; if (q != 0) { d = false } } if (d) { return } var b = new _bp(this._fa, p); var l = this._eb(this._fa._ba(f, 1), b, f); var o = l[0]; var n = l[1]; var k = this._ey(o); var e = this._di(n, k, m); for (var g = 0; g < k.length; g++) { var h = j.length - 1 - this._fa.log(k[g]); if (h < 0) { throw "ReedSolomonException Bad error location" } j[h] = _az._bd(j[h], e[g]) } }; this._eb = function (z, y, f) { if (z._ec < y._ec) { var w = z; z = y; y = w } var B = z; var k = y; var o = this._fa.One; var j = this._fa.Zero; var e = this._fa.Zero; var i = this._fa.One; while (k._ec >= Math.floor(f / 2)) { var x = B; var g = o; var v = e; B = k; o = j; e = i; if (B.Zero) { throw "r_{i-1} was zero" } k = x; var m = this._fa.Zero; var p = B._ex(B._ec); var h = this._fa.inverse(p); while (k._ec >= B._ec && !k.Zero) { var c = k._ec - B._ec; var A = this._fa.multiply(k._ex(k._ec), h); m = m._bd(this._fa._ba(c, A)); k = k._bd(B._dc(c, A)) } j = m.multiply1(o)._bd(g); i = m.multiply1(e)._bd(v) } var u = i._ex(0); if (u == 0) { throw "ReedSolomonException sigmaTilde(0) was zero" } var d = this._fa.inverse(u); var n = i.multiply2(d); var l = k.multiply2(d); return new Array(n, l) }; this._ey = function (f) { var g = f._ec; if (g == 1) { return new Array(f._ex(1)) } var b = new Array(g); var d = 0; for (var c = 1; c < 256 && d < g; c++) { if (f.evaluateAt(c) == 0) { b[d] = this._fa.inverse(c); d++ } } if (d != g) { throw "Error locator degree does not match number of roots" } return b }; this._di = function (f, h, g) {
                    var k = h.length; var l = new Array(k); for (var e = 0; e < k; e++) {
                        var b = this._fa.inverse(h[e]); var c = 1; for (var d = 0; d < k; d++) { if (e != d) { c = this._fa.multiply(c, _az._bd(1, this._fa.multiply(h[d], b))) } }
                        l[e] = this._fa.multiply(f.evaluateAt(b), this._fa.inverse(c)); if (g) { l[e] = this._fa.multiply(l[e], b) }
                    } return l
                }
            }
            function _bp(f, e) { if (e == null || e.length == 0) { throw "bad arguments" } this._fa = f; var c = e.length; if (c > 1 && e[0] == 0) { var d = 1; while (d < c && e[d] == 0) { d++ } if (d == c) { this._dd = f.Zero._dd } else { this._dd = new Array(c - d); for (var b = 0; b < this._dd.length; b++) { this._dd[b] = 0 } for (var a = 0; a < this._dd.length; a++) { this._dd[a] = e[d + a] } } } else { this._dd = e } this.__defineGetter__("Zero", function () { return this._dd[0] == 0 }); this.__defineGetter__("_ec", function () { return this._dd.length - 1 }); this.__defineGetter__("Coefficients", function () { return this._dd }); this._ex = function (g) { return this._dd[this._dd.length - 1 - g] }; this.evaluateAt = function (h) { if (h == 0) { return this._ex(0) } var l = this._dd.length; if (h == 1) { var g = 0; for (var k = 0; k < l; k++) { g = _az._bd(g, this._dd[k]) } return g } var j = this._dd[0]; for (var k = 1; k < l; k++) { j = _az._bd(this._fa.multiply(h, j), this._dd[k]) } return j }; this._bd = function (g) { if (this._fa != g._fa) { throw "GF256Polys do not have same _az _fa" } if (this.Zero) { return g } if (g.Zero) { return this } var o = this._dd; var n = g._dd; if (o.length > n.length) { var j = o; o = n; n = j } var h = new Array(n.length); var k = n.length - o.length; for (var m = 0; m < k; m++) { h[m] = n[m] } for (var l = k; l < n.length; l++) { h[l] = _az._bd(o[l - k], n[l]) } return new _bp(f, h) }; this.multiply1 = function (o) { if (this._fa != o._fa) { throw "GF256Polys do not have same _az _fa" } if (this.Zero || o.Zero) { return this._fa.Zero } var q = this._dd; var g = q.length; var l = o._dd; var n = l.length; var p = new Array(g + n - 1); for (var m = 0; m < g; m++) { var h = q[m]; for (var k = 0; k < n; k++) { p[m + k] = _az._bd(p[m + k], this._fa.multiply(h, l[k])) } } return new _bp(this._fa, p) }; this.multiply2 = function (g) { if (g == 0) { return this._fa.Zero } if (g == 1) { return this } var j = this._dd.length; var k = new Array(j); for (var h = 0; h < j; h++) { k[h] = this._fa.multiply(this._dd[h], g) } return new _bp(this._fa, k) }; this._dc = function (l, g) { if (l < 0) { throw "bad arguments" } if (g == 0) { return this._fa.Zero } var j = this._dd.length; var k = new Array(j + l); for (var h = 0; h < k.length; h++) { k[h] = 0 } for (var h = 0; h < j; h++) { k[h] = this._fa.multiply(this._dd[h], g) } return new _bp(this._fa, k) }; this.divide = function (l) { if (this._fa != l._fa) { throw "GF256Polys do not have same _az _fa" } if (l.Zero) { throw "Divide by 0" } var j = this._fa.Zero; var o = this; var g = l._ex(l._ec); var n = this._fa.inverse(g); while (o._ec >= l._ec && !o.Zero) { var m = o._ec - l._ec; var h = this._fa.multiply(o._ex(o._ec), n); var i = l._dc(m, h); var k = this._fa._ba(m, h); j = j._bd(k); o = o._bd(i) } return new Array(j, o) } } function _az(b) { this._gh = new Array(256); this._gi = new Array(256); var a = 1; for (var e = 0; e < 256; e++) { this._gh[e] = a; a <<= 1; if (a >= 256) { a ^= b } } for (var e = 0; e < 255; e++) { this._gi[this._gh[e]] = e } var d = new Array(1); d[0] = 0; this.zero = new _bp(this, new Array(d)); var c = new Array(1); c[0] = 1; this.one = new _bp(this, new Array(c)); this.__defineGetter__("Zero", function () { return this.zero }); this.__defineGetter__("One", function () { return this.one }); this._ba = function (j, f) { if (j < 0) { throw "bad arguments" } if (f == 0) { return this.zero } var h = new Array(j + 1); for (var g = 0; g < h.length; g++) { h[g] = 0 } h[0] = f; return new _bp(this, h) }; this.exp = function (f) { return this._gh[f] }; this.log = function (f) { if (f == 0) { throw "bad arguments" } return this._gi[f] }; this.inverse = function (f) { if (f == 0) { throw "System.ArithmeticException" } return this._gh[255 - this._gi[f]] }; this.multiply = function (g, f) { if (g == 0 || f == 0) { return 0 } if (g == 1) { return f } if (f == 1) { return g } return this._gh[(this._gi[g] + this._gi[f]) % 255] } } _az._bb = new _az(285); _az._bc = new _az(301); _az._bd = function (d, c) { return d ^ c }; var Decoder = {}; Decoder.rsDecoder = new _db(_az._bb); Decoder.correctErrors = function (g, b) { var d = g.length; var f = new Array(d); for (var e = 0; e < d; e++) { f[e] = g[e] & 255 } var a = g.length - b; try { Decoder.rsDecoder.decode(f, a) } catch (c) { throw c } for (var e = 0; e < b; e++) { g[e] = f[e] } }; Decoder.decode = function (q) { var b = new _cl(q); var o = b._cq(); var c = b._cm()._cg; var p = b._gk(); var a = _dl._gn(p, o, c); var f = 0; for (var k = 0; k < a.length; k++) { f += a[k]._du } var e = new Array(f); var n = 0; for (var h = 0; h < a.length; h++) { var m = a[h]; var d = m.Codewords; var g = m._du; Decoder.correctErrors(d, g); for (var k = 0; k < g; k++) { e[n++] = d[k] } } var l = new QRCodeDataBlockReader(e, o._fd, c.Bits); return l };

            var qrcode = {};
            qrcode.imagedata = null; qrcode.width = 0; qrcode.height = 0; qrcode.qrCodeSymbol = null; qrcode.debug = false; qrcode.maxImgSize = 1024 * 1024; qrcode._eo = [[10, 9, 8, 8], [12, 11, 16, 10], [14, 13, 16, 12]]; qrcode.callback = null; qrcode.vidSuccess = function (a) { qrcode.localstream = a; if (qrcode.webkit) { qrcode.video.src = window.webkitURL.createObjectURL(a) } else { if (qrcode.moz) { qrcode.video.mozSrcObject = a; qrcode.video.play() } else { qrcode.video.src = a } } qrcode.gUM = true; qrcode.canvas_qr2 = document.createElement("canvas"); qrcode.canvas_qr2.id = "qr-canvas"; qrcode.qrcontext2 = qrcode.canvas_qr2.getContext("2d"); qrcode.canvas_qr2.width = qrcode.video.videoWidth; qrcode.canvas_qr2.height = qrcode.video.videoHeight; setTimeout(qrcode.captureToCanvas, 500) }; qrcode.vidError = function (a) { qrcode.gUM = false; return }; qrcode.captureToCanvas = function () { if (qrcode.gUM) { try { if (qrcode.video.videoWidth == 0) { setTimeout(qrcode.captureToCanvas, 500); return } else { qrcode.canvas_qr2.width = qrcode.video.videoWidth; qrcode.canvas_qr2.height = qrcode.video.videoHeight } qrcode.qrcontext2.drawImage(qrcode.video, 0, 0); try { qrcode.decode() } catch (a) { console.log(a); setTimeout(qrcode.captureToCanvas, 500) } } catch (a) { console.log(a); setTimeout(qrcode.captureToCanvas, 500) } } }; qrcode.setWebcam = function (c) { var d = navigator; qrcode.video = document.getElementById(c); var a = true; if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) { try { navigator.mediaDevices.enumerateDevices().then(function (e) { e.forEach(function (f) { console.log("deb1"); if (f.kind === "videoinput") { if (f.label.toLowerCase().search("back") > -1) { a = [{ sourceId: f.deviceId }] } } console.log(f.kind + ": " + f.label + " id = " + f.deviceId) }) }) } catch (b) { console.log(b) } } else { console.log("no navigator.mediaDevices.enumerateDevices") } if (d.getUserMedia) { d.getUserMedia({ video: a, audio: false }, qrcode.vidSuccess, qrcode.vidError) } else { if (d.webkitGetUserMedia) { qrcode.webkit = true; d.webkitGetUserMedia({ video: a, audio: false }, qrcode.vidSuccess, qrcode.vidError) } else { if (d.mozGetUserMedia) { qrcode.moz = true; d.mozGetUserMedia({ video: a, audio: false }, qrcode.vidSuccess, qrcode.vidError) } } } }; qrcode.decode = function (d) { if (arguments.length == 0) { if (qrcode.canvas_qr2) { var b = qrcode.canvas_qr2; var a = qrcode.qrcontext2 } else { var b = document.getElementById("qr-canvas"); var a = b.getContext("2d") } qrcode.width = b.width; qrcode.height = b.height; qrcode.imagedata = a.getImageData(0, 0, qrcode.width, qrcode.height); qrcode.result = qrcode.process(a); if (qrcode.callback != null) { qrcode.callback(qrcode.result) } return qrcode.result } else { var c = new Image(); c.crossOrigin = "Anonymous"; c.onload = function () { var g = document.getElementById("out-canvas"); if (g != null) { var j = g.getContext("2d"); j.clearRect(0, 0, 320, 240); j.drawImage(c, 0, 0, 320, 240) } var i = document.createElement("canvas"); var h = i.getContext("2d"); var f = c.height; var l = c.width; if (c.width * c.height > qrcode.maxImgSize) { var k = c.width / c.height; f = Math.sqrt(qrcode.maxImgSize / k); l = k * f } i.width = l; i.height = f; h.drawImage(c, 0, 0, i.width, i.height); qrcode.width = i.width; qrcode.height = i.height; try { qrcode.imagedata = h.getImageData(0, 0, i.width, i.height) } catch (m) { qrcode.result = "Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!"; if (qrcode.callback != null) { qrcode.callback(qrcode.result) } return } try { qrcode.result = qrcode.process(h) } catch (m) { console.log(m); qrcode.result = "error decoding QR Code" } if (qrcode.callback != null) { qrcode.callback(qrcode.result) } }; c.onerror = function () { if (qrcode.callback != null) { qrcode.callback("Failed to load the image") } }; c.src = d } }; qrcode.isUrl = function (a) { var b = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; return b.test(a) }; qrcode.decode_url = function (b) { var d = ""; try { d = escape(b) } catch (c) { console.log(c); d = b } var a = ""; try { a = decodeURIComponent(d) } catch (c) { console.log(c); a = d } return a }; qrcode.decode_utf8 = function (a) { if (qrcode.isUrl(a)) { return qrcode.decode_url(a) } else { return a } }; qrcode.process = function (q) { var a = new Date().getTime(); var c = qrcode.grayScaleToBitmap(qrcode.grayscale()); if (qrcode.debug) { for (var m = 0; m < qrcode.height; m++) { for (var n = 0; n < qrcode.width; n++) { var o = (n * 4) + (m * qrcode.width * 4); qrcode.imagedata.data[o] = c[n + m * qrcode.width] ? 0 : 0; qrcode.imagedata.data[o + 1] = c[n + m * qrcode.width] ? 0 : 0; qrcode.imagedata.data[o + 2] = c[n + m * qrcode.width] ? 255 : 0 } } q.putImageData(qrcode.imagedata, 0, 0) } var h = new Detector(c); var p = h.detect(); if (qrcode.debug) { for (var m = 0; m < p.bits.Height; m++) { for (var n = 0; n < p.bits.Width; n++) { var o = (n * 4 * 2) + (m * 2 * qrcode.width * 4); qrcode.imagedata.data[o] = p.bits._ds(n, m) ? 0 : 0; qrcode.imagedata.data[o + 1] = p.bits._ds(n, m) ? 0 : 0; qrcode.imagedata.data[o + 2] = p.bits._ds(n, m) ? 255 : 0 } } q.putImageData(qrcode.imagedata, 0, 0) } var k = Decoder.decode(p.bits); var g = k.DataByte; var l = ""; for (var f = 0; f < g.length; f++) { for (var e = 0; e < g[f].length; e++) { l += String.fromCharCode(g[f][e]) } } var d = new Date().getTime(); var b = d - a; console.log(b); return qrcode.decode_utf8(l) }; qrcode.getPixel = function (b, d) { if (qrcode.width < b) { throw "point error" } if (qrcode.height < d) { throw "point error" } var a = (b * 4) + (d * qrcode.width * 4); var c = (qrcode.imagedata.data[a] * 33 + qrcode.imagedata.data[a + 1] * 34 + qrcode.imagedata.data[a + 2] * 33) / 100; return c }; qrcode.binarize = function (d) {
                var c = new Array(qrcode.width * qrcode.height);

                for (var e = 0; e < qrcode.height; e++) { for (var b = 0; b < qrcode.width; b++) { var a = qrcode.getPixel(b, e); c[b + e * qrcode.width] = a <= d ? true : false } } return c
            };
            qrcode._em = function (d) { var c = 4; var k = Math.floor(qrcode.width / c); var j = Math.floor(qrcode.height / c); var f = new Array(c); for (var g = 0; g < c; g++) { f[g] = new Array(c); for (var e = 0; e < c; e++) { f[g][e] = new Array(0, 0) } } for (var o = 0; o < c; o++) { for (var a = 0; a < c; a++) { f[a][o][0] = 255; for (var l = 0; l < j; l++) { for (var n = 0; n < k; n++) { var h = d[k * a + n + (j * o + l) * qrcode.width]; if (h < f[a][o][0]) { f[a][o][0] = h } if (h > f[a][o][1]) { f[a][o][1] = h } } } } } var m = new Array(c); for (var b = 0; b < c; b++) { m[b] = new Array(c) } for (var o = 0; o < c; o++) { for (var a = 0; a < c; a++) { m[a][o] = Math.floor((f[a][o][0] + f[a][o][1]) / 2) } } return m }; qrcode.grayScaleToBitmap = function (f) { var k = qrcode._em(f); var b = k.length; var e = Math.floor(qrcode.width / b); var d = Math.floor(qrcode.height / b); var h = new ArrayBuffer(qrcode.width * qrcode.height); var c = new Uint8Array(h); for (var j = 0; j < b; j++) { for (var a = 0; a < b; a++) { for (var g = 0; g < d; g++) { for (var i = 0; i < e; i++) { c[e * a + i + (d * j + g) * qrcode.width] = (f[e * a + i + (d * j + g) * qrcode.width] < k[a][j]) ? true : false } } } } return c }; qrcode.grayscale = function () { var e = new ArrayBuffer(qrcode.width * qrcode.height); var c = new Uint8Array(e); for (var d = 0; d < qrcode.height; d++) { for (var b = 0; b < qrcode.width; b++) { var a = qrcode.getPixel(b, d); c[b + d * qrcode.width] = a } } return c }; function _ew(a, b) { if (a >= 0) { return a >> b } else { return (a >> b) + (2 << ~b) } } var _gf = 3; var _eh = 57; var _el = 8; var _eg = 2; qrcode._er = function (c) { function b(m, k) { var n = m.X - k.X; var l = m.Y - k.Y; return Math.sqrt((n * n + l * l)) } function d(k, o, n) { var m = o.x; var l = o.y; return ((n.x - m) * (k.y - l)) - ((n.y - l) * (k.x - m)) } var i = b(c[0], c[1]); var f = b(c[1], c[2]); var e = b(c[0], c[2]); var a, j, h; if (f >= i && f >= e) { j = c[0]; a = c[1]; h = c[2] } else { if (e >= f && e >= i) { j = c[1]; a = c[0]; h = c[2] } else { j = c[2]; a = c[0]; h = c[1] } } if (d(a, j, h) < 0) { var g = a; a = h; h = g } c[0] = a; c[1] = j; c[2] = h }; function _cz(c, a, b) { this.x = c; this.y = a; this.count = 1; this._aj = b; this.__defineGetter__("_ei", function () { return this._aj }); this.__defineGetter__("Count", function () { return this.count }); this.__defineGetter__("X", function () { return this.x }); this.__defineGetter__("Y", function () { return this.y }); this._ek = function () { this.count++ }; this._ev = function (f, e, d) { if (Math.abs(e - this.y) <= f && Math.abs(d - this.x) <= f) { var g = Math.abs(f - this._aj); return g <= 1 || g / this._aj <= 1 } return false } } function _es(a) { this._go = a[0]; this._gu = a[1]; this._gr = a[2]; this.__defineGetter__("_gp", function () { return this._go }); this.__defineGetter__("_gq", function () { return this._gu }); this.__defineGetter__("_gs", function () { return this._gr }) } function _cc() {
                this.image = null; this._cv = []; this._ge = false; this._al = new Array(0, 0, 0, 0, 0); this._am = null; this.__defineGetter__("_da", function () { this._al[0] = 0; this._al[1] = 0; this._al[2] = 0; this._al[3] = 0; this._al[4] = 0; return this._al }); this._ao = function (f) { var b = 0; for (var d = 0; d < 5; d++) { var e = f[d]; if (e == 0) { return false } b += e } if (b < 7) { return false } var c = Math.floor((b << _el) / 7); var a = Math.floor(c / 2); return Math.abs(c - (f[0] << _el)) < a && Math.abs(c - (f[1] << _el)) < a && Math.abs(3 * c - (f[2] << _el)) < 3 * a && Math.abs(c - (f[3] << _el)) < a && Math.abs(c - (f[4] << _el)) < a }; this._an = function (b, a) { return (a - b[4] - b[3]) - b[2] / 2 }; this._ap = function (a, j, d, g) { var c = this.image; var h = qrcode.height; var b = this._da; var f = a; while (f >= 0 && c[j + f * qrcode.width]) { b[2]++; f-- } if (f < 0) { return NaN } while (f >= 0 && !c[j + f * qrcode.width] && b[1] <= d) { b[1]++; f-- } if (f < 0 || b[1] > d) { return NaN } while (f >= 0 && c[j + f * qrcode.width] && b[0] <= d) { b[0]++; f-- } if (b[0] > d) { return NaN } f = a + 1; while (f < h && c[j + f * qrcode.width]) { b[2]++; f++ } if (f == h) { return NaN } while (f < h && !c[j + f * qrcode.width] && b[3] < d) { b[3]++; f++ } if (f == h || b[3] >= d) { return NaN } while (f < h && c[j + f * qrcode.width] && b[4] < d) { b[4]++; f++ } if (b[4] >= d) { return NaN } var e = b[0] + b[1] + b[2] + b[3] + b[4]; if (5 * Math.abs(e - g) >= 2 * g) { return NaN } return this._ao(b) ? this._an(b, f) : NaN }; this._ej = function (b, a, e, h) { var d = this.image; var i = qrcode.width; var c = this._da; var g = b; while (g >= 0 && d[g + a * qrcode.width]) { c[2]++; g-- } if (g < 0) { return NaN } while (g >= 0 && !d[g + a * qrcode.width] && c[1] <= e) { c[1]++; g-- } if (g < 0 || c[1] > e) { return NaN } while (g >= 0 && d[g + a * qrcode.width] && c[0] <= e) { c[0]++; g-- } if (c[0] > e) { return NaN } g = b + 1; while (g < i && d[g + a * qrcode.width]) { c[2]++; g++ } if (g == i) { return NaN } while (g < i && !d[g + a * qrcode.width] && c[3] < e) { c[3]++; g++ } if (g == i || c[3] >= e) { return NaN } while (g < i && d[g + a * qrcode.width] && c[4] < e) { c[4]++; g++ } if (c[4] >= e) { return NaN } var f = c[0] + c[1] + c[2] + c[3] + c[4]; if (5 * Math.abs(f - h) >= h) { return NaN } return this._ao(c) ? this._an(c, g) : NaN }; this._cu = function (c, f, e) { var d = c[0] + c[1] + c[2] + c[3] + c[4]; var n = this._an(c, e); var b = this._ap(f, Math.floor(n), c[2], d); if (!isNaN(b)) { n = this._ej(Math.floor(n), Math.floor(b), c[2], d); if (!isNaN(n)) { var l = d / 7; var m = false; var h = this._cv.length; for (var g = 0; g < h; g++) { var a = this._cv[g]; if (a._ev(l, b, n)) { a._ek(); m = true; break } } if (!m) { var k = new _cz(n, b, l); this._cv.push(k); if (this._am != null) { this._am._ep(k) } } return true } } return false }; this._ee = function () {
                    var h = this._cv.length; if (h < 3) { throw "Couldn't find enough finder patterns (found " + h + ")" } if (h > 3) {
                        var b = 0; var j = 0; for (var d = 0; d < h; d++) { var g = this._cv[d]._ei; b += g; j += (g * g) } var a = b / h; this._cv.sort(function (m, l) { var k = Math.abs(l._ei - a); var i = Math.abs(m._ei - a); if (k < i) { return (-1) } else { if (k == i) { return 0 } else { return 1 } } }); var e = Math.sqrt(j / h - a * a); var c = Math.max(0.2 * a, e);

                        for (var d = this._cv.length - 1; d >= 0; d--) { var f = this._cv[d]; if (Math.abs(f._ei - a) > c) { this._cv.splice(d, 1) } }
                    } if (this._cv.length > 3) { this._cv.sort(function (k, i) { if (k.count > i.count) { return -1 } if (k.count < i.count) { return 1 } return 0 }) } return new Array(this._cv[0], this._cv[1], this._cv[2])
                }; this._eq = function () { var b = this._cv.length; if (b <= 1) { return 0 } var c = null; for (var d = 0; d < b; d++) { var a = this._cv[d]; if (a.Count >= _eg) { if (c == null) { c = a } else { this._ge = true; return Math.floor((Math.abs(c.X - a.X) - Math.abs(c.Y - a.Y)) / 2) } } } return 0 }; this._cx = function () { var g = 0; var c = 0; var a = this._cv.length; for (var d = 0; d < a; d++) { var f = this._cv[d]; if (f.Count >= _eg) { g++; c += f._ei } } if (g < 3) { return false } var e = c / a; var b = 0; for (var d = 0; d < a; d++) { f = this._cv[d]; b += Math.abs(f._ei - e) } return b <= 0.05 * c }; this._ce = function (e) { var o = false; this.image = e; var n = qrcode.height; var k = qrcode.width; var a = Math.floor((3 * n) / (4 * _eh)); if (a < _gf || o) { a = _gf } var g = false; var d = new Array(5); for (var h = a - 1; h < n && !g; h += a) { d[0] = 0; d[1] = 0; d[2] = 0; d[3] = 0; d[4] = 0; var b = 0; for (var f = 0; f < k; f++) { if (e[f + h * qrcode.width]) { if ((b & 1) == 1) { b++ } d[b]++ } else { if ((b & 1) == 0) { if (b == 4) { if (this._ao(d)) { var c = this._cu(d, h, f); if (c) { a = 2; if (this._ge) { g = this._cx() } else { var m = this._eq(); if (m > d[2]) { h += m - d[2] - a; f = k - 1 } } } else { do { f++ } while (f < k && !e[f + h * qrcode.width]); f-- } b = 0; d[0] = 0; d[1] = 0; d[2] = 0; d[3] = 0; d[4] = 0 } else { d[0] = d[2]; d[1] = d[3]; d[2] = d[4]; d[3] = 1; d[4] = 0; b = 3 } } else { d[++b]++ } } else { d[b]++ } } } if (this._ao(d)) { var c = this._cu(d, h, k); if (c) { a = d[0]; if (this._ge) { g = this._cx() } } } } var l = this._ee(); qrcode._er(l); return new _es(l) }
            }
            function _ai(c, a, b) { this.x = c; this.y = a; this.count = 1; this._aj = b; this.__defineGetter__("_ei", function () { return this._aj }); this.__defineGetter__("Count", function () { return this.count }); this.__defineGetter__("X", function () { return Math.floor(this.x) }); this.__defineGetter__("Y", function () { return Math.floor(this.y) }); this._ek = function () { this.count++ }; this._ev = function (f, e, d) { if (Math.abs(e - this.y) <= f && Math.abs(d - this.x) <= f) { var g = Math.abs(f - this._aj); return g <= 1 || g / this._aj <= 1 } return false } } function _ak(g, c, b, f, a, e, d) {
                this.image = g; this._cv = new Array(); this.startX = c; this.startY = b; this.width = f; this.height = a; this._ef = e; this._al = new Array(0, 0, 0); this._am = d; this._an = function (i, h) { return (h - i[2]) - i[1] / 2 }; this._ao = function (l) { var k = this._ef; var h = k / 2; for (var j = 0; j < 3; j++) { if (Math.abs(k - l[j]) >= h) { return false } } return true }; this._ap = function (h, q, l, o) { var k = this.image; var p = qrcode.height; var j = this._al; j[0] = 0; j[1] = 0; j[2] = 0; var n = h; while (n >= 0 && k[q + n * qrcode.width] && j[1] <= l) { j[1]++; n-- } if (n < 0 || j[1] > l) { return NaN } while (n >= 0 && !k[q + n * qrcode.width] && j[0] <= l) { j[0]++; n-- } if (j[0] > l) { return NaN } n = h + 1; while (n < p && k[q + n * qrcode.width] && j[1] <= l) { j[1]++; n++ } if (n == p || j[1] > l) { return NaN } while (n < p && !k[q + n * qrcode.width] && j[2] <= l) { j[2]++; n++ } if (j[2] > l) { return NaN } var m = j[0] + j[1] + j[2]; if (5 * Math.abs(m - o) >= 2 * o) { return NaN } return this._ao(j) ? this._an(j, n) : NaN }; this._cu = function (l, o, n) {
                    var m = l[0] + l[1] + l[2]; var t = this._an(l, n); var k = this._ap(o, Math.floor(t), 2 * l[1], m); if (!isNaN(k)) {
                        var s = (l[0] + l[1] + l[2]) / 3;
                        var q = this._cv.length; for (var p = 0; p < q; p++) {
                            var h = this._cv[p];
                            if (h._ev(s, k, t)) { return new _ai(t, k, s) }
                        } var r = new _ai(t, k, s); this._cv.push(r); if (this._am != null) { this._am._ep(r) }
                    } return null
                }; this.find = function () { var p = this.startX; var s = this.height; var q = p + f; var r = b + (s >> 1); var m = new Array(0, 0, 0); for (var k = 0; k < s; k++) { var o = r + ((k & 1) == 0 ? ((k + 1) >> 1) : -((k + 1) >> 1)); m[0] = 0; m[1] = 0; m[2] = 0; var n = p; while (n < q && !g[n + qrcode.width * o]) { n++ } var h = 0; while (n < q) { if (g[n + o * qrcode.width]) { if (h == 1) { m[h]++ } else { if (h == 2) { if (this._ao(m)) { var l = this._cu(m, o, n); if (l != null) { return l } } m[0] = m[2]; m[1] = 1; m[2] = 0; h = 1 } else { m[++h]++ } } } else { if (h == 1) { h++ } m[h]++ } n++ } if (this._ao(m)) { var l = this._cu(m, o, q); if (l != null) { return l } } } if (!(this._cv.length == 0)) { return this._cv[0] } throw "Couldn't find enough alignment patterns" }
            }
            function QRCodeDataBlockReader(c, a, b) {
                this._ed = 0; this._cw = 7; this.dataLength = 0; this.blocks = c; this._en = b; if (a <= 9) { this.dataLengthMode = 0 } else { if (a >= 10 && a <= 26) { this.dataLengthMode = 1 } else { if (a >= 27 && a <= 40) { this.dataLengthMode = 2 } } } this._gd = function (f) { var k = 0; if (f < this._cw + 1) { var m = 0; for (var e = 0; e < f; e++) { m += (1 << e) } m <<= (this._cw - f + 1); k = (this.blocks[this._ed] & m) >> (this._cw - f + 1); this._cw -= f; return k } else { if (f < this._cw + 1 + 8) { var j = 0; for (var e = 0; e < this._cw + 1; e++) { j += (1 << e) } k = (this.blocks[this._ed] & j) << (f - (this._cw + 1)); this._ed++; k += ((this.blocks[this._ed]) >> (8 - (f - (this._cw + 1)))); this._cw = this._cw - f % 8; if (this._cw < 0) { this._cw = 8 + this._cw } return k } else { if (f < this._cw + 1 + 16) { var j = 0; var h = 0; for (var e = 0; e < this._cw + 1; e++) { j += (1 << e) } var g = (this.blocks[this._ed] & j) << (f - (this._cw + 1)); this._ed++; var d = this.blocks[this._ed] << (f - (this._cw + 1 + 8)); this._ed++; for (var e = 0; e < f - (this._cw + 1 + 8); e++) { h += (1 << e) } h <<= 8 - (f - (this._cw + 1 + 8)); var l = (this.blocks[this._ed] & h) >> (8 - (f - (this._cw + 1 + 8))); k = g + d + l; this._cw = this._cw - (f - 8) % 8; if (this._cw < 0) { this._cw = 8 + this._cw } return k } else { return 0 } } } }; this.NextMode = function () { if ((this._ed > this.blocks.length - this._en - 2)) { return 0 } else { return this._gd(4) } }; this.getDataLength = function (d) { var e = 0; while (true) { if ((d >> e) == 1) { break } e++ } return this._gd(qrcode._eo[this.dataLengthMode][e]) }; this.getRomanAndFigureString = function (h) { var f = h; var g = 0; var j = ""; var d = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", " ", "$", "%", "*", "+", "-", ".", "/", ":"); do { if (f > 1) { g = this._gd(11); var i = Math.floor(g / 45); var e = g % 45; j += d[i]; j += d[e]; f -= 2 } else { if (f == 1) { g = this._gd(6); j += d[g]; f -= 1 } } } while (f > 0); return j }; this.getFigureString = function (f) { var d = f; var e = 0; var g = ""; do { if (d >= 3) { e = this._gd(10); if (e < 100) { g += "0" } if (e < 10) { g += "0" } d -= 3 } else { if (d == 2) { e = this._gd(7); if (e < 10) { g += "0" } d -= 2 } else { if (d == 1) { e = this._gd(4); d -= 1 } } } g += e } while (d > 0); return g }; this.get8bitByteArray = function (g) { var e = g; var f = 0; var d = new Array(); do { f = this._gd(8); d.push(f); e-- } while (e > 0); return d }; this.getKanjiString = function (j) { var g = j; var i = 0; var h = ""; do { i = this._gd(13); var e = i % 192; var f = i / 192; var k = (f << 8) + e; var d = 0; if (k + 33088 <= 40956) { d = k + 33088 } else { d = k + 49472 } h += String.fromCharCode(d); g-- } while (g > 0); return h }; this.parseECIValue = function () {
                    var f = 0; var e = this._gd(8); if ((e & 128) == 0) { f = e & 127 }
                    if ((e & 192) == 128) { var d = this._gd(8); f = ((e & 63) << 8) | d } if ((e & 224) == 192) { var g = this._gd(8); f = ((e & 31) << 16) | g } return f
                }; this.__defineGetter__("DataByte", function () { var h = new Array(); var e = 1; var f = 2; var d = 4; var n = 7; var p = 8; do { var l = this.NextMode(); if (l == 0) { if (h.length > 0) { break } else { throw "Empty data block" } } if (l != e && l != f && l != d && l != p && l != n) { throw "Invalid mode: " + l + " in (block:" + this._ed + " bit:" + this._cw + ")" } if (l == n) { var o = this.parseECIValue() } else { var g = this.getDataLength(l); if (g < 1) { throw "Invalid data length: " + g } switch (l) { case e: var m = this.getFigureString(g); var k = new Array(m.length); for (var i = 0; i < m.length; i++) { k[i] = m.charCodeAt(i) } h.push(k); break; case f: var m = this.getRomanAndFigureString(g); var k = new Array(m.length); for (var i = 0; i < m.length; i++) { k[i] = m.charCodeAt(i) } h.push(k); break; case d: var o = this.get8bitByteArray(g); h.push(o); break; case p: var m = this.getKanjiString(g); h.push(m); break } } } while (true); return h })
            };

            var gCtx = null;
            var gCanvas = null;
            var c = 0;
            var stype = 0;
            var gUM = false;
            var webkit = false;
            var moz = false;
            var v = null;

            var imghtml = '<div id="qrfile"><canvas id="out-canvas" width="320" height="240"></canvas>' +
                '<div id="imghelp">drag and drop a QRCode here' +
                '<br>or select a file' +
                '<input type="file" onchange={e=>{this.handleFiles(this.files)}}/>' +
                '</div>' +
                '</div>';

            var vidhtml = '<video id="vide_v" autoplay></video>';

            function dragenter(e) {
                e.stopPropagation();
                e.preventDefault();
            }

            function dragover(e) {
                e.stopPropagation();
                e.preventDefault();
            }
            function drop(e) {
                e.stopPropagation();
                e.preventDefault();

                var dt = e.dataTransfer;
                var files = dt.files;
                if (files.length > 0) {
                    handleFiles(files);
                }
                else
                    if (dt.getData('URL')) {
                        qrcode.decode(dt.getData('URL'));
                    }
            }

            const handleFiles = function (f) {
                var o = [];

                for (var i = 0; i < f.length; i++) {
                    var reader = new FileReader();
                    reader.onload = (function (theFile) {
                        return function (e) {
                            gCtx.clearRect(0, 0, gCanvas.width, gCanvas.height);
                            qrcode.decode(e.target.result);
                        };
                    })(f[i]);
                    reader.readAsDataURL(f[i]);
                }
            }
            this.handleFiles = handleFiles

            function initCanvas(w, h) {
                gCanvas = document.getElementById("qr-canvas");
                gCanvas.style.width = w + "px";
                gCanvas.style.height = h + "px";
                gCanvas.width = w;
                gCanvas.height = h;
                gCtx = gCanvas.getContext("2d");
                gCtx.clearRect(0, 0, w, h);
            }


            function captureToCanvas() {
                if (stype != 1)
                    return;
                if (gUM) {
                    try {
                        gCtx.drawImage(v, 0, 0);
                        try {
                            qrcode.decode();
                        }
                        catch (e) {
                            console.log(e);
                            setTimeout(captureToCanvas, 500);
                        };
                    }
                    catch (e) {
                        console.log(e);
                        setTimeout(captureToCanvas, 500);
                    };
                }
            }

            function htmlEntities(str) {
                return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
            }

            function read(a) {
                message.info(a)
                // var html = "<br>";
                // if (a.indexOf("http://") === 0 || a.indexOf("https://") === 0)
                //     html += "<a target='_blank' href='" + a + "'>" + a + "</a><br>";
                // html += "<b>" + htmlEntities(a) + "</b><br><br>";
                // document.getElementById("result").innerHTML = html;
            }

            function isCanvasSupported() {
                var elem = document.createElement('canvas');
                return !!(elem.getContext && elem.getContext('2d'));
            }
            function success(stream) {

                v.srcObject = stream;
                v.play();

                gUM = true;
                setTimeout(captureToCanvas, 500);
            }

            function errorget(error) {
                gUM = false;
                return;
            }

            function load() {
                if (isCanvasSupported() && window.File && window.FileReader) {
                    initCanvas(800, 600);
                    qrcode.callback = read;
                    // document.getElementById("qrdecoder_mainbody").style.display = "inline";
                    setwebcam();
                }
                else {
                    // document.getElementById("qrdecoder_mainbody").style.display = "inline";
                    // document.getElementById("qrdecoder_mainbody").innerHTML = '<p id="mp1">QR code scanner for HTML5 capable browsers</p><br>' +
                    //     '<br><p id="mp2">sorry your browser is not supported</p><br><br>' +
                    //     '<p id="mp1">try <a href="http://www.mozilla.com/firefox"><img src="firefox.png"/></a> or <a href="http://chrome.google.com"><img src="chrome_logo.gif"/></a> or <a href="http://www.opera.com"><img src="Opera-logo.png"/></a></p>';
                }
            }

            const setwebcam = function () {

                var options = true;
                if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
                    try {
                        navigator.mediaDevices.enumerateDevices()
                            .then(function (devices) {
                                message.info('enumerateDevices then')
                                devices.forEach(function (device) {
                                    if (device.kind === 'videoinput') {
                                        if (device.label.toLowerCase().search("back") > -1)
                                            options = { 'deviceId': { 'exact': device.deviceId }, 'facingMode': 'environment' };
                                    }
                                    console.log(device.kind + ": " + device.label + " id = " + device.deviceId);
                                });
                                setwebcam2(options);
                            });
                    }
                    catch (e) {
                        // message.info('enumerateDevices error')
                        console.log(e);
                    }
                }
                else {
                    // message.info("no navigator.mediaDevices.enumerateDevices");
                    setwebcam2(options);
                }

            }
            this.setwebcam = setwebcam

            function setwebcam2(options) {
                console.log(options);
                // document.getElementById("result").innerHTML = "- scanning -";
                if (stype == 1) {
                    setTimeout(captureToCanvas, 500);
                    return;
                }
                var n = navigator;
                // document.getElementById("qrdecoder_outdiv").innerHTML = vidhtml;
                v = document.getElementById("vide_v");


                if (n.mediaDevices && n.mediaDevices.getUserMedia) {
                    n.mediaDevices.getUserMedia({ video: options, audio: false }).
                        then(function (stream) {
                            success(stream);
                        }).catch(function (error) {
                            errorget(error)
                            message.info('getUserMedia error:' + error)
                        });
                }
                else
                    if (n.getUserMedia) {
                        webkit = true;
                        n.getUserMedia({ video: options, audio: false }, success, error);
                    }
                    else
                        if (n.webkitGetUserMedia) {
                            webkit = true;
                            n.webkitGetUserMedia({ video: options, audio: false }, success, error);
                        }

                // document.getElementById("qrimg").style.opacity = 0.2;
                // document.getElementById("webcamimg").style.opacity = 1.0;

                stype = 1;
                setTimeout(captureToCanvas, 500);
            }

            function setimg() {
                // document.getElementById("result").innerHTML = "";
                if (stype == 2)
                    return;
                // document.getElementById("qrdecoder_outdiv").innerHTML = imghtml;
                //document.getElementById("qrimg").src="qrimg.png";
                //document.getElementById("webcamimg").src="webcam2.png";
                // document.getElementById("qrimg").style.opacity = 1.0;
                // document.getElementById("webcamimg").style.opacity = 0.2;
                var qrfile = document.getElementById("qrfile");
                qrfile.addEventListener("dragenter", dragenter, false);
                qrfile.addEventListener("dragover", dragover, false);
                qrfile.addEventListener("drop", drop, false);
                stype = 2;
            }
            load()
        }, 1000);
    }
    // captureToCanvas() {
    //     flash = document.getElementById("embedflash");
    //     flash.ccCapture();
    //     this.qrcode.decode();
    // }
    render() {
        return (
            <Fragment>
                {/* <div id="qrdecoder_mainbody"> */}
                <div style={{ overflow: 'hidden', height: 500 }}>
                    <video id="vide_v" autoplay style={{ height: 500 }}></video>
                    <canvas id="qr-canvas" style={{ opacity: 0 }}></canvas>
                </div>
            </Fragment>
        )
    }
}
export default Qrdecoder


// //Grid.js
            // var GridSampler = {};
            // GridSampler.checkAndNudgePoints = function (image, points) {
            //     var width = qrcode.width;
            //     var height = qrcode.height;
            //     // Check and nudge points from start until we see some that are OK:
            //     var nudged = true;
            //     for (var offset = 0; offset < points.length && nudged; offset += 2) {
            //         var x = Math.floor(points[offset]);
            //         var y = Math.floor(points[offset + 1]);
            //         if (x < - 1 || x > width || y < - 1 || y > height) {
            //             throw "Error.checkAndNudgePoints ";
            //         }
            //         nudged = false;
            //         if (x == - 1) {
            //             points[offset] = 0.0;
            //             nudged = true;
            //         }
            //         else if (x == width) {
            //             points[offset] = width - 1;
            //             nudged = true;
            //         }
            //         if (y == - 1) {
            //             points[offset + 1] = 0.0;
            //             nudged = true;
            //         }
            //         else if (y == height) {
            //             points[offset + 1] = height - 1;
            //             nudged = true;
            //         }
            //     }
            //     // Check and nudge points from end:
            //     nudged = true;
            //     for (var offset = points.length - 2; offset >= 0 && nudged; offset -= 2) {
            //         var x = Math.floor(points[offset]);
            //         var y = Math.floor(points[offset + 1]);
            //         if (x < - 1 || x > width || y < - 1 || y > height) {
            //             throw "Error.checkAndNudgePoints ";
            //         }
            //         nudged = false;
            //         if (x == - 1) {
            //             points[offset] = 0.0;
            //             nudged = true;
            //         }
            //         else if (x == width) {
            //             points[offset] = width - 1;
            //             nudged = true;
            //         }
            //         if (y == - 1) {
            //             points[offset + 1] = 0.0;
            //             nudged = true;
            //         }
            //         else if (y == height) {
            //             points[offset + 1] = height - 1;
            //             nudged = true;
            //         }
            //     }
            // }
            // GridSampler.sampleGrid3 = function (image, dimension, transform) {
            //     var bits = new BitMatrix(dimension);
            //     var points = new Array(dimension << 1);
            //     for (var y = 0; y < dimension; y++) {
            //         var max = points.length;
            //         var iValue = y + 0.5;
            //         for (var x = 0; x < max; x += 2) {
            //             points[x] = (x >> 1) + 0.5;
            //             points[x + 1] = iValue;
            //         }
            //         transform.transformPoints1(points);
            //         // Quick check to see if points transformed to something inside the image;
            //         // sufficient to check the endpoints
            //         GridSampler.checkAndNudgePoints(image, points);
            //         try {
            //             for (var x = 0; x < max; x += 2) {
            //                 //var xpoint = (Math.floor( points[x]) * 4) + (Math.floor( points[x + 1]) * qrcode.width * 4);
            //                 var bit = image[Math.floor(points[x]) + qrcode.width * Math.floor(points[x + 1])];
            //                 //qrcode.imagedata.data[xpoint] = bit?255:0;
            //                 //qrcode.imagedata.data[xpoint+1] = bit?255:0;
            //                 //qrcode.imagedata.data[xpoint+2] = 0;
            //                 //qrcode.imagedata.data[xpoint+3] = 255;
            //                 //bits[x >> 1][ y]=bit;
            //                 if (bit)
            //                     bits.set_Renamed(x >> 1, y);
            //             }
            //         }
            //         catch (aioobe) {
            //             // This feels wrong, but, sometimes if the finder patterns are misidentified, the resulting
            //             // transform gets "twisted" such that it maps a straight line of points to a set of points
            //             // whose endpoints are in bounds, but others are not. There is probably some mathematical
            //             // way to detect this about the transformation that I don't know yet.
            //             // This results in an ugly runtime exception despite our clever checks above -- can't have
            //             // that. We could check each point's coordinates but that feels duplicative. We settle for
            //             // catching and wrapping ArrayIndexOutOfBoundsException.
            //             throw "Error.checkAndNudgePoints";
            //         }
            //     }
            //     return bits;
            // }
            // GridSampler.sampleGridx = function (image, dimension, p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY) {
            //     var transform = PerspectiveTransform.quadrilateralToQuadrilateral(p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY);
            //     return GridSampler.sampleGrid3(image, dimension, transform);
            // }

            // //version.js
            // function ECB(count, dataCodewords) {
            //     this.count = count;
            //     this.dataCodewords = dataCodewords;

            //     this.__defineGetter__("Count", function () {
            //         return this.count;
            //     });
            //     this.__defineGetter__("DataCodewords", function () {
            //         return this.dataCodewords;
            //     });
            // }

            // function ECBlocks(ecCodewordsPerBlock, ecBlocks1, ecBlocks2) {
            //     this.ecCodewordsPerBlock = ecCodewordsPerBlock;
            //     if (ecBlocks2)
            //         this.ecBlocks = new Array(ecBlocks1, ecBlocks2);
            //     else
            //         this.ecBlocks = new Array(ecBlocks1);

            //     this.__defineGetter__("ECCodewordsPerBlock", function () {
            //         return this.ecCodewordsPerBlock;
            //     });

            //     this.__defineGetter__("TotalECCodewords", function () {
            //         return this.ecCodewordsPerBlock * this.NumBlocks;
            //     });

            //     this.__defineGetter__("NumBlocks", function () {
            //         var total = 0;
            //         for (var i = 0; i < this.ecBlocks.length; i++) {
            //             total += this.ecBlocks[i].length;
            //         }
            //         return total;
            //     });

            //     this.getECBlocks = function () {
            //         return this.ecBlocks;
            //     }
            // }

            // function Version(versionNumber, alignmentPatternCenters, ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4) {
            //     this.versionNumber = versionNumber;
            //     this.alignmentPatternCenters = alignmentPatternCenters;
            //     this.ecBlocks = new Array(ecBlocks1, ecBlocks2, ecBlocks3, ecBlocks4);

            //     var total = 0;
            //     var ecCodewords = ecBlocks1.ECCodewordsPerBlock;
            //     var ecbArray = ecBlocks1.getECBlocks();
            //     for (var i = 0; i < ecbArray.length; i++) {
            //         var ecBlock = ecbArray[i];
            //         total += ecBlock.Count * (ecBlock.DataCodewords + ecCodewords);
            //     }
            //     this.totalCodewords = total;

            //     this.__defineGetter__("VersionNumber", function () {
            //         return this.versionNumber;
            //     });

            //     this.__defineGetter__("AlignmentPatternCenters", function () {
            //         return this.alignmentPatternCenters;
            //     });
            //     this.__defineGetter__("TotalCodewords", function () {
            //         return this.totalCodewords;
            //     });
            //     this.__defineGetter__("DimensionForVersion", function () {
            //         return 17 + 4 * this.versionNumber;
            //     });

            //     this.buildFunctionPattern = function () {
            //         var dimension = this.DimensionForVersion;
            //         var bitMatrix = new BitMatrix(dimension);

            //         // Top left finder pattern + separator + format
            //         bitMatrix.setRegion(0, 0, 9, 9);
            //         // Top right finder pattern + separator + format
            //         bitMatrix.setRegion(dimension - 8, 0, 8, 9);
            //         // Bottom left finder pattern + separator + format
            //         bitMatrix.setRegion(0, dimension - 8, 9, 8);

            //         // Alignment patterns
            //         var max = this.alignmentPatternCenters.length;
            //         for (var x = 0; x < max; x++) {
            //             var i = this.alignmentPatternCenters[x] - 2;
            //             for (var y = 0; y < max; y++) {
            //                 if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) {
            //                     // No alignment patterns near the three finder paterns
            //                     continue;
            //                 }
            //                 bitMatrix.setRegion(this.alignmentPatternCenters[y] - 2, i, 5, 5);
            //             }
            //         }

            //         // Vertical timing pattern
            //         bitMatrix.setRegion(6, 9, 1, dimension - 17);
            //         // Horizontal timing pattern
            //         bitMatrix.setRegion(9, 6, dimension - 17, 1);

            //         if (this.versionNumber > 6) {
            //             // Version info, top right
            //             bitMatrix.setRegion(dimension - 11, 0, 3, 6);
            //             // Version info, bottom left
            //             bitMatrix.setRegion(0, dimension - 11, 6, 3);
            //         }

            //         return bitMatrix;
            //     }
            //     this.getECBlocksForLevel = function (ecLevel) {
            //         return this.ecBlocks[ecLevel.ordinal()];
            //     }
            // }

            // Version.VERSION_DECODE_INFO = new Array(0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78, 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, 0x2542E, 0x26A64, 0x27541, 0x28C69);

            // Version.VERSIONS = buildVersions();

            // Version.getVersionForNumber = function (versionNumber) {
            //     if (versionNumber < 1 || versionNumber > 40) {
            //         throw "ArgumentException";
            //     }
            //     return Version.VERSIONS[versionNumber - 1];
            // }

            // Version.getProvisionalVersionForDimension = function (dimension) {
            //     if (dimension % 4 != 1) {
            //         throw "Error getProvisionalVersionForDimension";
            //     }
            //     try {
            //         return Version.getVersionForNumber((dimension - 17) >> 2);
            //     }
            //     catch (iae) {
            //         throw "Error getVersionForNumber";
            //     }
            // }

            // Version.decodeVersionInformation = function (versionBits) {
            //     var bestDifference = 0xffffffff;
            //     var bestVersion = 0;
            //     for (var i = 0; i < Version.VERSION_DECODE_INFO.length; i++) {
            //         var targetVersion = Version.VERSION_DECODE_INFO[i];
            //         // Do the version info bits match exactly? done.
            //         if (targetVersion == versionBits) {
            //             return this.getVersionForNumber(i + 7);
            //         }
            //         // Otherwise see if this is the closest to a real version info bit string
            //         // we have seen so far
            //         var bitsDifference = FormatInformation.numBitsDiffering(versionBits, targetVersion);
            //         if (bitsDifference < bestDifference) {
            //             bestVersion = i + 7;
            //             bestDifference = bitsDifference;
            //         }
            //     }
            //     // We can tolerate up to 3 bits of error since no two version info codewords will
            //     // differ in less than 4 bits.
            //     if (bestDifference <= 3) {
            //         return this.getVersionForNumber(bestVersion);
            //     }
            //     // If we didn't find a close enough match, fail
            //     return null;
            // }

            // function buildVersions() {
            //     return new Array(new Version(1, new Array(), new ECBlocks(7, new ECB(1, 19)), new ECBlocks(10, new ECB(1, 16)), new ECBlocks(13, new ECB(1, 13)), new ECBlocks(17, new ECB(1, 9))),
            //         new Version(2, new Array(6, 18), new ECBlocks(10, new ECB(1, 34)), new ECBlocks(16, new ECB(1, 28)), new ECBlocks(22, new ECB(1, 22)), new ECBlocks(28, new ECB(1, 16))),
            //         new Version(3, new Array(6, 22), new ECBlocks(15, new ECB(1, 55)), new ECBlocks(26, new ECB(1, 44)), new ECBlocks(18, new ECB(2, 17)), new ECBlocks(22, new ECB(2, 13))),
            //         new Version(4, new Array(6, 26), new ECBlocks(20, new ECB(1, 80)), new ECBlocks(18, new ECB(2, 32)), new ECBlocks(26, new ECB(2, 24)), new ECBlocks(16, new ECB(4, 9))),
            //         new Version(5, new Array(6, 30), new ECBlocks(26, new ECB(1, 108)), new ECBlocks(24, new ECB(2, 43)), new ECBlocks(18, new ECB(2, 15), new ECB(2, 16)), new ECBlocks(22, new ECB(2, 11), new ECB(2, 12))),
            //         new Version(6, new Array(6, 34), new ECBlocks(18, new ECB(2, 68)), new ECBlocks(16, new ECB(4, 27)), new ECBlocks(24, new ECB(4, 19)), new ECBlocks(28, new ECB(4, 15))),
            //         new Version(7, new Array(6, 22, 38), new ECBlocks(20, new ECB(2, 78)), new ECBlocks(18, new ECB(4, 31)), new ECBlocks(18, new ECB(2, 14), new ECB(4, 15)), new ECBlocks(26, new ECB(4, 13), new ECB(1, 14))),
            //         new Version(8, new Array(6, 24, 42), new ECBlocks(24, new ECB(2, 97)), new ECBlocks(22, new ECB(2, 38), new ECB(2, 39)), new ECBlocks(22, new ECB(4, 18), new ECB(2, 19)), new ECBlocks(26, new ECB(4, 14), new ECB(2, 15))),
            //         new Version(9, new Array(6, 26, 46), new ECBlocks(30, new ECB(2, 116)), new ECBlocks(22, new ECB(3, 36), new ECB(2, 37)), new ECBlocks(20, new ECB(4, 16), new ECB(4, 17)), new ECBlocks(24, new ECB(4, 12), new ECB(4, 13))),
            //         new Version(10, new Array(6, 28, 50), new ECBlocks(18, new ECB(2, 68), new ECB(2, 69)), new ECBlocks(26, new ECB(4, 43), new ECB(1, 44)), new ECBlocks(24, new ECB(6, 19), new ECB(2, 20)), new ECBlocks(28, new ECB(6, 15), new ECB(2, 16))),
            //         new Version(11, new Array(6, 30, 54), new ECBlocks(20, new ECB(4, 81)), new ECBlocks(30, new ECB(1, 50), new ECB(4, 51)), new ECBlocks(28, new ECB(4, 22), new ECB(4, 23)), new ECBlocks(24, new ECB(3, 12), new ECB(8, 13))),
            //         new Version(12, new Array(6, 32, 58), new ECBlocks(24, new ECB(2, 92), new ECB(2, 93)), new ECBlocks(22, new ECB(6, 36), new ECB(2, 37)), new ECBlocks(26, new ECB(4, 20), new ECB(6, 21)), new ECBlocks(28, new ECB(7, 14), new ECB(4, 15))),
            //         new Version(13, new Array(6, 34, 62), new ECBlocks(26, new ECB(4, 107)), new ECBlocks(22, new ECB(8, 37), new ECB(1, 38)), new ECBlocks(24, new ECB(8, 20), new ECB(4, 21)), new ECBlocks(22, new ECB(12, 11), new ECB(4, 12))),
            //         new Version(14, new Array(6, 26, 46, 66), new ECBlocks(30, new ECB(3, 115), new ECB(1, 116)), new ECBlocks(24, new ECB(4, 40), new ECB(5, 41)), new ECBlocks(20, new ECB(11, 16), new ECB(5, 17)), new ECBlocks(24, new ECB(11, 12), new ECB(5, 13))),
            //         new Version(15, new Array(6, 26, 48, 70), new ECBlocks(22, new ECB(5, 87), new ECB(1, 88)), new ECBlocks(24, new ECB(5, 41), new ECB(5, 42)), new ECBlocks(30, new ECB(5, 24), new ECB(7, 25)), new ECBlocks(24, new ECB(11, 12), new ECB(7, 13))),
            //         new Version(16, new Array(6, 26, 50, 74), new ECBlocks(24, new ECB(5, 98), new ECB(1, 99)), new ECBlocks(28, new ECB(7, 45), new ECB(3, 46)), new ECBlocks(24, new ECB(15, 19), new ECB(2, 20)), new ECBlocks(30, new ECB(3, 15), new ECB(13, 16))),
            //         new Version(17, new Array(6, 30, 54, 78), new ECBlocks(28, new ECB(1, 107), new ECB(5, 108)), new ECBlocks(28, new ECB(10, 46), new ECB(1, 47)), new ECBlocks(28, new ECB(1, 22), new ECB(15, 23)), new ECBlocks(28, new ECB(2, 14), new ECB(17, 15))),
            //         new Version(18, new Array(6, 30, 56, 82), new ECBlocks(30, new ECB(5, 120), new ECB(1, 121)), new ECBlocks(26, new ECB(9, 43), new ECB(4, 44)), new ECBlocks(28, new ECB(17, 22), new ECB(1, 23)), new ECBlocks(28, new ECB(2, 14), new ECB(19, 15))),
            //         new Version(19, new Array(6, 30, 58, 86), new ECBlocks(28, new ECB(3, 113), new ECB(4, 114)), new ECBlocks(26, new ECB(3, 44), new ECB(11, 45)), new ECBlocks(26, new ECB(17, 21), new ECB(4, 22)), new ECBlocks(26, new ECB(9, 13), new ECB(16, 14))),
            //         new Version(20, new Array(6, 34, 62, 90), new ECBlocks(28, new ECB(3, 107), new ECB(5, 108)), new ECBlocks(26, new ECB(3, 41), new ECB(13, 42)), new ECBlocks(30, new ECB(15, 24), new ECB(5, 25)), new ECBlocks(28, new ECB(15, 15), new ECB(10, 16))),
            //         new Version(21, new Array(6, 28, 50, 72, 94), new ECBlocks(28, new ECB(4, 116), new ECB(4, 117)), new ECBlocks(26, new ECB(17, 42)), new ECBlocks(28, new ECB(17, 22), new ECB(6, 23)), new ECBlocks(30, new ECB(19, 16), new ECB(6, 17))),
            //         new Version(22, new Array(6, 26, 50, 74, 98), new ECBlocks(28, new ECB(2, 111), new ECB(7, 112)), new ECBlocks(28, new ECB(17, 46)), new ECBlocks(30, new ECB(7, 24), new ECB(16, 25)), new ECBlocks(24, new ECB(34, 13))),
            //         new Version(23, new Array(6, 30, 54, 74, 102), new ECBlocks(30, new ECB(4, 121), new ECB(5, 122)), new ECBlocks(28, new ECB(4, 47), new ECB(14, 48)), new ECBlocks(30, new ECB(11, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(16, 15), new ECB(14, 16))),
            //         new Version(24, new Array(6, 28, 54, 80, 106), new ECBlocks(30, new ECB(6, 117), new ECB(4, 118)), new ECBlocks(28, new ECB(6, 45), new ECB(14, 46)), new ECBlocks(30, new ECB(11, 24), new ECB(16, 25)), new ECBlocks(30, new ECB(30, 16), new ECB(2, 17))),
            //         new Version(25, new Array(6, 32, 58, 84, 110), new ECBlocks(26, new ECB(8, 106), new ECB(4, 107)), new ECBlocks(28, new ECB(8, 47), new ECB(13, 48)), new ECBlocks(30, new ECB(7, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(22, 15), new ECB(13, 16))),
            //         new Version(26, new Array(6, 30, 58, 86, 114), new ECBlocks(28, new ECB(10, 114), new ECB(2, 115)), new ECBlocks(28, new ECB(19, 46), new ECB(4, 47)), new ECBlocks(28, new ECB(28, 22), new ECB(6, 23)), new ECBlocks(30, new ECB(33, 16), new ECB(4, 17))),
            //         new Version(27, new Array(6, 34, 62, 90, 118), new ECBlocks(30, new ECB(8, 122), new ECB(4, 123)), new ECBlocks(28, new ECB(22, 45), new ECB(3, 46)), new ECBlocks(30, new ECB(8, 23), new ECB(26, 24)), new ECBlocks(30, new ECB(12, 15), new ECB(28, 16))),
            //         new Version(28, new Array(6, 26, 50, 74, 98, 122), new ECBlocks(30, new ECB(3, 117), new ECB(10, 118)), new ECBlocks(28, new ECB(3, 45), new ECB(23, 46)), new ECBlocks(30, new ECB(4, 24), new ECB(31, 25)), new ECBlocks(30, new ECB(11, 15), new ECB(31, 16))),
            //         new Version(29, new Array(6, 30, 54, 78, 102, 126), new ECBlocks(30, new ECB(7, 116), new ECB(7, 117)), new ECBlocks(28, new ECB(21, 45), new ECB(7, 46)), new ECBlocks(30, new ECB(1, 23), new ECB(37, 24)), new ECBlocks(30, new ECB(19, 15), new ECB(26, 16))),
            //         new Version(30, new Array(6, 26, 52, 78, 104, 130), new ECBlocks(30, new ECB(5, 115), new ECB(10, 116)), new ECBlocks(28, new ECB(19, 47), new ECB(10, 48)), new ECBlocks(30, new ECB(15, 24), new ECB(25, 25)), new ECBlocks(30, new ECB(23, 15), new ECB(25, 16))),
            //         new Version(31, new Array(6, 30, 56, 82, 108, 134), new ECBlocks(30, new ECB(13, 115), new ECB(3, 116)), new ECBlocks(28, new ECB(2, 46), new ECB(29, 47)), new ECBlocks(30, new ECB(42, 24), new ECB(1, 25)), new ECBlocks(30, new ECB(23, 15), new ECB(28, 16))),
            //         new Version(32, new Array(6, 34, 60, 86, 112, 138), new ECBlocks(30, new ECB(17, 115)), new ECBlocks(28, new ECB(10, 46), new ECB(23, 47)), new ECBlocks(30, new ECB(10, 24), new ECB(35, 25)), new ECBlocks(30, new ECB(19, 15), new ECB(35, 16))),
            //         new Version(33, new Array(6, 30, 58, 86, 114, 142), new ECBlocks(30, new ECB(17, 115), new ECB(1, 116)), new ECBlocks(28, new ECB(14, 46), new ECB(21, 47)), new ECBlocks(30, new ECB(29, 24), new ECB(19, 25)), new ECBlocks(30, new ECB(11, 15), new ECB(46, 16))),
            //         new Version(34, new Array(6, 34, 62, 90, 118, 146), new ECBlocks(30, new ECB(13, 115), new ECB(6, 116)), new ECBlocks(28, new ECB(14, 46), new ECB(23, 47)), new ECBlocks(30, new ECB(44, 24), new ECB(7, 25)), new ECBlocks(30, new ECB(59, 16), new ECB(1, 17))),
            //         new Version(35, new Array(6, 30, 54, 78, 102, 126, 150), new ECBlocks(30, new ECB(12, 121), new ECB(7, 122)), new ECBlocks(28, new ECB(12, 47), new ECB(26, 48)), new ECBlocks(30, new ECB(39, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(22, 15), new ECB(41, 16))),
            //         new Version(36, new Array(6, 24, 50, 76, 102, 128, 154), new ECBlocks(30, new ECB(6, 121), new ECB(14, 122)), new ECBlocks(28, new ECB(6, 47), new ECB(34, 48)), new ECBlocks(30, new ECB(46, 24), new ECB(10, 25)), new ECBlocks(30, new ECB(2, 15), new ECB(64, 16))),
            //         new Version(37, new Array(6, 28, 54, 80, 106, 132, 158), new ECBlocks(30, new ECB(17, 122), new ECB(4, 123)), new ECBlocks(28, new ECB(29, 46), new ECB(14, 47)), new ECBlocks(30, new ECB(49, 24), new ECB(10, 25)), new ECBlocks(30, new ECB(24, 15), new ECB(46, 16))),
            //         new Version(38, new Array(6, 32, 58, 84, 110, 136, 162), new ECBlocks(30, new ECB(4, 122), new ECB(18, 123)), new ECBlocks(28, new ECB(13, 46), new ECB(32, 47)), new ECBlocks(30, new ECB(48, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(42, 15), new ECB(32, 16))),
            //         new Version(39, new Array(6, 26, 54, 82, 110, 138, 166), new ECBlocks(30, new ECB(20, 117), new ECB(4, 118)), new ECBlocks(28, new ECB(40, 47), new ECB(7, 48)), new ECBlocks(30, new ECB(43, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(10, 15), new ECB(67, 16))),
            //         new Version(40, new Array(6, 30, 58, 86, 114, 142, 170), new ECBlocks(30, new ECB(19, 118), new ECB(6, 119)), new ECBlocks(28, new ECB(18, 47), new ECB(31, 48)), new ECBlocks(30, new ECB(34, 24), new ECB(34, 25)), new ECBlocks(30, new ECB(20, 15), new ECB(61, 16))));
            // }


            // //detector.js
            // function PerspectiveTransform(a11, a21, a31, a12, a22, a32, a13, a23, a33) {
            //     this.a11 = a11;
            //     this.a12 = a12;
            //     this.a13 = a13;
            //     this.a21 = a21;
            //     this.a22 = a22;
            //     this.a23 = a23;
            //     this.a31 = a31;
            //     this.a32 = a32;
            //     this.a33 = a33;
            //     this.transformPoints1 = function (points) {
            //         var max = points.length;
            //         var a11 = this.a11;
            //         var a12 = this.a12;
            //         var a13 = this.a13;
            //         var a21 = this.a21;
            //         var a22 = this.a22;
            //         var a23 = this.a23;
            //         var a31 = this.a31;
            //         var a32 = this.a32;
            //         var a33 = this.a33;
            //         for (var i = 0; i < max; i += 2) {
            //             var x = points[i];
            //             var y = points[i + 1];
            //             var denominator = a13 * x + a23 * y + a33;
            //             points[i] = (a11 * x + a21 * y + a31) / denominator;
            //             points[i + 1] = (a12 * x + a22 * y + a32) / denominator;
            //         }
            //     }
            //     this.transformPoints2 = function (xValues, yValues) {
            //         var n = xValues.length;
            //         for (var i = 0; i < n; i++) {
            //             var x = xValues[i];
            //             var y = yValues[i];
            //             var denominator = this.a13 * x + this.a23 * y + this.a33;
            //             xValues[i] = (this.a11 * x + this.a21 * y + this.a31) / denominator;
            //             yValues[i] = (this.a12 * x + this.a22 * y + this.a32) / denominator;
            //         }
            //     }

            //     this.buildAdjoint = function () {
            //         // Adjoint is the transpose of the cofactor matrix:
            //         return new PerspectiveTransform(this.a22 * this.a33 - this.a23 * this.a32, this.a23 * this.a31 - this.a21 * this.a33, this.a21 * this.a32 - this.a22 * this.a31, this.a13 * this.a32 - this.a12 * this.a33, this.a11 * this.a33 - this.a13 * this.a31, this.a12 * this.a31 - this.a11 * this.a32, this.a12 * this.a23 - this.a13 * this.a22, this.a13 * this.a21 - this.a11 * this.a23, this.a11 * this.a22 - this.a12 * this.a21);
            //     }
            //     this.times = function (other) {
            //         return new PerspectiveTransform(this.a11 * other.a11 + this.a21 * other.a12 + this.a31 * other.a13, this.a11 * other.a21 + this.a21 * other.a22 + this.a31 * other.a23, this.a11 * other.a31 + this.a21 * other.a32 + this.a31 * other.a33, this.a12 * other.a11 + this.a22 * other.a12 + this.a32 * other.a13, this.a12 * other.a21 + this.a22 * other.a22 + this.a32 * other.a23, this.a12 * other.a31 + this.a22 * other.a32 + this.a32 * other.a33, this.a13 * other.a11 + this.a23 * other.a12 + this.a33 * other.a13, this.a13 * other.a21 + this.a23 * other.a22 + this.a33 * other.a23, this.a13 * other.a31 + this.a23 * other.a32 + this.a33 * other.a33);
            //     }

            // }

            // PerspectiveTransform.quadrilateralToQuadrilateral = function (x0, y0, x1, y1, x2, y2, x3, y3, x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p) {

            //     var qToS = this.quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3);
            //     var sToQ = this.squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p);
            //     return sToQ.times(qToS);
            // }

            // PerspectiveTransform.squareToQuadrilateral = function (x0, y0, x1, y1, x2, y2, x3, y3) {
            //     var dy2 = y3 - y2;
            //     var dy3 = y0 - y1 + y2 - y3;
            //     if (dy2 == 0.0 && dy3 == 0.0) {
            //         return new PerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0, y2 - y1, y0, 0.0, 0.0, 1.0);
            //     }
            //     else {
            //         var dx1 = x1 - x2;
            //         var dx2 = x3 - x2;
            //         var dx3 = x0 - x1 + x2 - x3;
            //         var dy1 = y1 - y2;
            //         var denominator = dx1 * dy2 - dx2 * dy1;
            //         var a13 = (dx3 * dy2 - dx2 * dy3) / denominator;
            //         var a23 = (dx1 * dy3 - dx3 * dy1) / denominator;
            //         return new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0, a13, a23, 1.0);
            //     }
            // }

            // PerspectiveTransform.quadrilateralToSquare = function (x0, y0, x1, y1, x2, y2, x3, y3) {
            //     // Here, the adjoint serves as the inverse:
            //     return this.squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3).buildAdjoint();
            // }

            // function DetectorResult(bits, points) {
            //     this.bits = bits;
            //     this.points = points;
            // }

            // function Detector(image) {
            //     this.image = image;
            //     this.resultPointCallback = null;

            //     this.sizeOfBlackWhiteBlackRun = function (fromX, fromY, toX, toY) {
            //         // Mild variant of Bresenham's algorithm;
            //         // see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm
            //         var steep = Math.abs(toY - fromY) > Math.abs(toX - fromX);
            //         if (steep) {
            //             var temp = fromX;
            //             fromX = fromY;
            //             fromY = temp;
            //             temp = toX;
            //             toX = toY;
            //             toY = temp;
            //         }

            //         var dx = Math.abs(toX - fromX);
            //         var dy = Math.abs(toY - fromY);
            //         var error = - dx >> 1;
            //         var ystep = fromY < toY ? 1 : - 1;
            //         var xstep = fromX < toX ? 1 : - 1;
            //         var state = 0; // In black pixels, looking for white, first or second time
            //         for (var x = fromX, y = fromY; x != toX; x += xstep) {

            //             var realX = steep ? y : x;
            //             var realY = steep ? x : y;
            //             if (state == 1) {
            //                 // In white pixels, looking for black
            //                 if (this.image[realX + realY * qrcode.width]) {
            //                     state++;
            //                 }
            //             }
            //             else {
            //                 if (!this.image[realX + realY * qrcode.width]) {
            //                     state++;
            //                 }
            //             }

            //             if (state == 3) {
            //                 // Found black, white, black, and stumbled back onto white; done
            //                 var diffX = x - fromX;
            //                 var diffY = y - fromY;
            //                 return Math.sqrt((diffX * diffX + diffY * diffY));
            //             }
            //             error += dy;
            //             if (error > 0) {
            //                 if (y == toY) {
            //                     break;
            //                 }
            //                 y += ystep;
            //                 error -= dx;
            //             }
            //         }
            //         var diffX2 = toX - fromX;
            //         var diffY2 = toY - fromY;
            //         return Math.sqrt((diffX2 * diffX2 + diffY2 * diffY2));
            //     }


            //     this.sizeOfBlackWhiteBlackRunBothWays = function (fromX, fromY, toX, toY) {

            //         var result = this.sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY);

            //         // Now count other way -- don't run off image though of course
            //         var scale = 1.0;
            //         var otherToX = fromX - (toX - fromX);
            //         if (otherToX < 0) {
            //             scale = fromX / (fromX - otherToX);
            //             otherToX = 0;
            //         }
            //         else if (otherToX >= qrcode.width) {
            //             scale = (qrcode.width - 1 - fromX) / (otherToX - fromX);
            //             otherToX = qrcode.width - 1;
            //         }
            //         var otherToY = Math.floor(fromY - (toY - fromY) * scale);

            //         scale = 1.0;
            //         if (otherToY < 0) {
            //             scale = fromY / (fromY - otherToY);
            //             otherToY = 0;
            //         }
            //         else if (otherToY >= qrcode.height) {
            //             scale = (qrcode.height - 1 - fromY) / (otherToY - fromY);
            //             otherToY = qrcode.height - 1;
            //         }
            //         otherToX = Math.floor(fromX + (otherToX - fromX) * scale);

            //         result += this.sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);
            //         return result - 1.0; // -1 because we counted the middle pixel twice
            //     }



            //     this.calculateModuleSizeOneWay = function (pattern, otherPattern) {
            //         var moduleSizeEst1 = this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(pattern.X), Math.floor(pattern.Y), Math.floor(otherPattern.X), Math.floor(otherPattern.Y));
            //         var moduleSizeEst2 = this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(otherPattern.X), Math.floor(otherPattern.Y), Math.floor(pattern.X), Math.floor(pattern.Y));
            //         if (isNaN(moduleSizeEst1)) {
            //             return moduleSizeEst2 / 7.0;
            //         }
            //         if (isNaN(moduleSizeEst2)) {
            //             return moduleSizeEst1 / 7.0;
            //         }
            //         // Average them, and divide by 7 since we've counted the width of 3 black modules,
            //         // and 1 white and 1 black module on either side. Ergo, divide sum by 14.
            //         return (moduleSizeEst1 + moduleSizeEst2) / 14.0;
            //     }


            //     this.calculateModuleSize = function (topLeft, topRight, bottomLeft) {
            //         // Take the average
            //         return (this.calculateModuleSizeOneWay(topLeft, topRight) + this.calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0;
            //     }

            //     this.distance = function (pattern1, pattern2) {
            //         var xDiff = pattern1.X - pattern2.X;
            //         var yDiff = pattern1.Y - pattern2.Y;
            //         return Math.sqrt((xDiff * xDiff + yDiff * yDiff));
            //     }
            //     this.computeDimension = function (topLeft, topRight, bottomLeft, moduleSize) {

            //         var tltrCentersDimension = Math.round(this.distance(topLeft, topRight) / moduleSize);
            //         var tlblCentersDimension = Math.round(this.distance(topLeft, bottomLeft) / moduleSize);
            //         var dimension = ((tltrCentersDimension + tlblCentersDimension) >> 1) + 7;
            //         switch (dimension & 0x03) {

            //             // mod 4
            //             case 0:
            //                 dimension++;
            //                 break;
            //             // 1? do nothing

            //             case 2:
            //                 dimension--;
            //                 break;

            //             case 3:
            //                 throw "Error";
            //         }
            //         return dimension;
            //     }

            //     this.findAlignmentInRegion = function (overallEstModuleSize, estAlignmentX, estAlignmentY, allowanceFactor) {
            //         // Look for an alignment pattern (3 modules in size) around where it
            //         // should be
            //         var allowance = Math.floor(allowanceFactor * overallEstModuleSize);
            //         var alignmentAreaLeftX = Math.max(0, estAlignmentX - allowance);
            //         var alignmentAreaRightX = Math.min(qrcode.width - 1, estAlignmentX + allowance);
            //         if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) {
            //             throw "Error";
            //         }

            //         var alignmentAreaTopY = Math.max(0, estAlignmentY - allowance);
            //         var alignmentAreaBottomY = Math.min(qrcode.height - 1, estAlignmentY + allowance);

            //         var alignmentFinder = new AlignmentPatternFinder(this.image, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, this.resultPointCallback);
            //         return alignmentFinder.find();
            //     }

            //     this.createTransform = function (topLeft, topRight, bottomLeft, alignmentPattern, dimension) {
            //         var dimMinusThree = dimension - 3.5;
            //         var bottomRightX;
            //         var bottomRightY;
            //         var sourceBottomRightX;
            //         var sourceBottomRightY;
            //         if (alignmentPattern != null) {
            //             bottomRightX = alignmentPattern.X;
            //             bottomRightY = alignmentPattern.Y;
            //             sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0;
            //         }
            //         else {
            //             // Don't have an alignment pattern, just make up the bottom-right point
            //             bottomRightX = (topRight.X - topLeft.X) + bottomLeft.X;
            //             bottomRightY = (topRight.Y - topLeft.Y) + bottomLeft.Y;
            //             sourceBottomRightX = sourceBottomRightY = dimMinusThree;
            //         }

            //         var transform = PerspectiveTransform.quadrilateralToQuadrilateral(3.5, 3.5, dimMinusThree, 3.5, sourceBottomRightX, sourceBottomRightY, 3.5, dimMinusThree, topLeft.X, topLeft.Y, topRight.X, topRight.Y, bottomRightX, bottomRightY, bottomLeft.X, bottomLeft.Y);

            //         return transform;
            //     }

            //     this.sampleGrid = function (image, transform, dimension) {

            //         var sampler = GridSampler;
            //         return sampler.sampleGrid3(image, dimension, transform);
            //     }

            //     this.processFinderPatternInfo = function (info) {

            //         var topLeft = info.TopLeft;
            //         var topRight = info.TopRight;
            //         var bottomLeft = info.BottomLeft;

            //         var moduleSize = this.calculateModuleSize(topLeft, topRight, bottomLeft);
            //         if (moduleSize < 1.0) {
            //             throw "Error";
            //         }
            //         var dimension = this.computeDimension(topLeft, topRight, bottomLeft, moduleSize);
            //         var provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
            //         var modulesBetweenFPCenters = provisionalVersion.DimensionForVersion - 7;

            //         var alignmentPattern = null;
            //         // Anything above version 1 has an alignment pattern
            //         if (provisionalVersion.AlignmentPatternCenters.length > 0) {

            //             // Guess where a "bottom right" finder pattern would have been
            //             var bottomRightX = topRight.X - topLeft.X + bottomLeft.X;
            //             var bottomRightY = topRight.Y - topLeft.Y + bottomLeft.Y;

            //             // Estimate that alignment pattern is closer by 3 modules
            //             // from "bottom right" to known top left location
            //             var correctionToTopLeft = 1.0 - 3.0 / modulesBetweenFPCenters;
            //             var estAlignmentX = Math.floor(topLeft.X + correctionToTopLeft * (bottomRightX - topLeft.X));
            //             var estAlignmentY = Math.floor(topLeft.Y + correctionToTopLeft * (bottomRightY - topLeft.Y));

            //             // Kind of arbitrary -- expand search radius before giving up
            //             for (var i = 4; i <= 16; i <<= 1) {
            //                 //try
            //                 //{
            //                 alignmentPattern = this.findAlignmentInRegion(moduleSize, estAlignmentX, estAlignmentY, i);
            //                 break;
            //                 //}
            //                 //catch (re)
            //                 //{
            //                 // try next round
            //                 //}
            //             }
            //             // If we didn't find alignment pattern... well try anyway without it
            //         }

            //         var transform = this.createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);

            //         var bits = this.sampleGrid(this.image, transform, dimension);

            //         var points;
            //         if (alignmentPattern == null) {
            //             points = new Array(bottomLeft, topLeft, topRight);
            //         }
            //         else {
            //             points = new Array(bottomLeft, topLeft, topRight, alignmentPattern);
            //         }
            //         return new DetectorResult(bits, points);
            //     }



            //     this.detect = function () {
            //         var info = new FinderPatternFinder().findFinderPattern(this.image);

            //         return this.processFinderPatternInfo(info);
            //     }
            // }

            // //formaint.js
            // var FORMAT_INFO_MASK_QR = 0x5412;
            // var FORMAT_INFO_DECODE_LOOKUP = new Array(new Array(0x5412, 0x00), new Array(0x5125, 0x01), new Array(0x5E7C, 0x02), new Array(0x5B4B, 0x03), new Array(0x45F9, 0x04), new Array(0x40CE, 0x05), new Array(0x4F97, 0x06), new Array(0x4AA0, 0x07), new Array(0x77C4, 0x08), new Array(0x72F3, 0x09), new Array(0x7DAA, 0x0A), new Array(0x789D, 0x0B), new Array(0x662F, 0x0C), new Array(0x6318, 0x0D), new Array(0x6C41, 0x0E), new Array(0x6976, 0x0F), new Array(0x1689, 0x10), new Array(0x13BE, 0x11), new Array(0x1CE7, 0x12), new Array(0x19D0, 0x13), new Array(0x0762, 0x14), new Array(0x0255, 0x15), new Array(0x0D0C, 0x16), new Array(0x083B, 0x17), new Array(0x355F, 0x18), new Array(0x3068, 0x19), new Array(0x3F31, 0x1A), new Array(0x3A06, 0x1B), new Array(0x24B4, 0x1C), new Array(0x2183, 0x1D), new Array(0x2EDA, 0x1E), new Array(0x2BED, 0x1F));
            // var BITS_SET_IN_HALF_BYTE = new Array(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);


            // function FormatInformation(formatInfo) {
            //     this.errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03);
            //     this.dataMask = (formatInfo & 0x07);

            //     this.__defineGetter__("ErrorCorrectionLevel", function () {
            //         return this.errorCorrectionLevel;
            //     });
            //     this.__defineGetter__("DataMask", function () {
            //         return this.dataMask;
            //     });
            //     this.GetHashCode = function () {
            //         return (this.errorCorrectionLevel.ordinal() << 3) | this.dataMask;
            //     }
            //     this.Equals = function (o) {
            //         var other = o;
            //         return this.errorCorrectionLevel == other.errorCorrectionLevel && this.dataMask == other.dataMask;
            //     }
            // }

            // FormatInformation.numBitsDiffering = function (a, b) {
            //     a ^= b; // a now has a 1 bit exactly where its bit differs with b's
            //     // Count bits set quickly with a series of lookups:
            //     return BITS_SET_IN_HALF_BYTE[a & 0x0F] + BITS_SET_IN_HALF_BYTE[(URShift(a, 4) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 8) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 12) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 16) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 20) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 24) & 0x0F)] + BITS_SET_IN_HALF_BYTE[(URShift(a, 28) & 0x0F)];
            // }

            // FormatInformation.decodeFormatInformation = function (maskedFormatInfo) {
            //     var formatInfo = FormatInformation.doDecodeFormatInformation(maskedFormatInfo);
            //     if (formatInfo != null) {
            //         return formatInfo;
            //     }
            //     // Should return null, but, some QR codes apparently
            //     // do not mask this info. Try again by actually masking the pattern
            //     // first
            //     return FormatInformation.doDecodeFormatInformation(maskedFormatInfo ^ FORMAT_INFO_MASK_QR);
            // }
            // FormatInformation.doDecodeFormatInformation = function (maskedFormatInfo) {
            //     // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing
            //     var bestDifference = 0xffffffff;
            //     var bestFormatInfo = 0;
            //     for (var i = 0; i < FORMAT_INFO_DECODE_LOOKUP.length; i++) {
            //         var decodeInfo = FORMAT_INFO_DECODE_LOOKUP[i];
            //         var targetInfo = decodeInfo[0];
            //         if (targetInfo == maskedFormatInfo) {
            //             // Found an exact match
            //             return new FormatInformation(decodeInfo[1]);
            //         }
            //         var bitsDifference = this.numBitsDiffering(maskedFormatInfo, targetInfo);
            //         if (bitsDifference < bestDifference) {
            //             bestFormatInfo = decodeInfo[1];
            //             bestDifference = bitsDifference;
            //         }
            //     }
            //     // Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits
            //     // differing means we found a match
            //     if (bestDifference <= 3) {
            //         return new FormatInformation(bestFormatInfo);
            //     }
            //     return null;
            // }


            // //errorlevel.js
            // function ErrorCorrectionLevel(ordinal, bits, name) {
            //     this.ordinal_Renamed_Field = ordinal;
            //     this.bits = bits;
            //     this.name = name;
            //     this.__defineGetter__("Bits", function () {
            //         return this.bits;
            //     });
            //     this.__defineGetter__("Name", function () {
            //         return this.name;
            //     });
            //     this.ordinal = function () {
            //         return this.ordinal_Renamed_Field;
            //     }
            // }

            // ErrorCorrectionLevel.forBits = function (bits) {
            //     if (bits < 0 || bits >= FOR_BITS.length) {
            //         throw "ArgumentException";
            //     }
            //     return FOR_BITS[bits];
            // }

            // var L = new ErrorCorrectionLevel(0, 0x01, "L");
            // var M = new ErrorCorrectionLevel(1, 0x00, "M");
            // var Q = new ErrorCorrectionLevel(2, 0x03, "Q");
            // var H = new ErrorCorrectionLevel(3, 0x02, "H");
            // var FOR_BITS = new Array(M, L, H, Q);


            // //bitmat.js
            // function BitMatrix(width, height) {
            //     if (!height)
            //         height = width;
            //     if (width < 1 || height < 1) {
            //         throw "Both dimensions must be greater than 0";
            //     }
            //     this.width = width;
            //     this.height = height;
            //     var rowSize = width >> 5;
            //     if ((width & 0x1f) != 0) {
            //         rowSize++;
            //     }
            //     this.rowSize = rowSize;
            //     this.bits = new Array(rowSize * height);
            //     for (var i = 0; i < this.bits.length; i++)
            //         this.bits[i] = 0;

            //     this.__defineGetter__("Width", function () {
            //         return this.width;
            //     });
            //     this.__defineGetter__("Height", function () {
            //         return this.height;
            //     });
            //     this.__defineGetter__("Dimension", function () {
            //         if (this.width != this.height) {
            //             throw "Can't call getDimension() on a non-square matrix";
            //         }
            //         return this.width;
            //     });

            //     this.get_Renamed = function (x, y) {
            //         var offset = y * this.rowSize + (x >> 5);
            //         return ((URShift(this.bits[offset], (x & 0x1f))) & 1) != 0;
            //     }
            //     this.set_Renamed = function (x, y) {
            //         var offset = y * this.rowSize + (x >> 5);
            //         this.bits[offset] |= 1 << (x & 0x1f);
            //     }
            //     this.flip = function (x, y) {
            //         var offset = y * this.rowSize + (x >> 5);
            //         this.bits[offset] ^= 1 << (x & 0x1f);
            //     }
            //     this.clear = function () {
            //         var max = this.bits.length;
            //         for (var i = 0; i < max; i++) {
            //             this.bits[i] = 0;
            //         }
            //     }
            //     this.setRegion = function (left, top, width, height) {
            //         if (top < 0 || left < 0) {
            //             throw "Left and top must be nonnegative";
            //         }
            //         if (height < 1 || width < 1) {
            //             throw "Height and width must be at least 1";
            //         }
            //         var right = left + width;
            //         var bottom = top + height;
            //         if (bottom > this.height || right > this.width) {
            //             throw "The region must fit inside the matrix";
            //         }
            //         for (var y = top; y < bottom; y++) {
            //             var offset = y * this.rowSize;
            //             for (var x = left; x < right; x++) {
            //                 this.bits[offset + (x >> 5)] |= 1 << (x & 0x1f);
            //             }
            //         }
            //     }
            // }

            // //datablock.js
            // function DataBlock(numDataCodewords, codewords) {
            //     this.numDataCodewords = numDataCodewords;
            //     this.codewords = codewords;

            //     this.__defineGetter__("NumDataCodewords", function () {
            //         return this.numDataCodewords;
            //     });
            //     this.__defineGetter__("Codewords", function () {
            //         return this.codewords;
            //     });
            // }
            // DataBlock.getDataBlocks = function (rawCodewords, version, ecLevel) {

            //     if (rawCodewords.length != version.TotalCodewords) {
            //         throw "ArgumentException";
            //     }

            //     // Figure out the number and size of data blocks used by this version and
            //     // error correction level
            //     var ecBlocks = version.getECBlocksForLevel(ecLevel);

            //     // First count the total number of data blocks
            //     var totalBlocks = 0;
            //     var ecBlockArray = ecBlocks.getECBlocks();
            //     for (var i = 0; i < ecBlockArray.length; i++) {
            //         totalBlocks += ecBlockArray[i].Count;
            //     }

            //     // Now establish DataBlocks of the appropriate size and number of data codewords
            //     var result = new Array(totalBlocks);
            //     var numResultBlocks = 0;
            //     for (var j = 0; j < ecBlockArray.length; j++) {
            //         var ecBlock = ecBlockArray[j];
            //         for (var i = 0; i < ecBlock.Count; i++) {
            //             var numDataCodewords = ecBlock.DataCodewords;
            //             var numBlockCodewords = ecBlocks.ECCodewordsPerBlock + numDataCodewords;
            //             result[numResultBlocks++] = new DataBlock(numDataCodewords, new Array(numBlockCodewords));
            //         }
            //     }

            //     // All blocks have the same amount of data, except that the last n
            //     // (where n may be 0) have 1 more byte. Figure out where these start.
            //     var shorterBlocksTotalCodewords = result[0].codewords.length;
            //     var longerBlocksStartAt = result.length - 1;
            //     while (longerBlocksStartAt >= 0) {
            //         var numCodewords = result[longerBlocksStartAt].codewords.length;
            //         if (numCodewords == shorterBlocksTotalCodewords) {
            //             break;
            //         }
            //         longerBlocksStartAt--;
            //     }
            //     longerBlocksStartAt++;

            //     var shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.ECCodewordsPerBlock;
            //     // The last elements of result may be 1 element longer;
            //     // first fill out as many elements as all of them have
            //     var rawCodewordsOffset = 0;
            //     for (var i = 0; i < shorterBlocksNumDataCodewords; i++) {
            //         for (var j = 0; j < numResultBlocks; j++) {
            //             result[j].codewords[i] = rawCodewords[rawCodewordsOffset++];
            //         }
            //     }
            //     // Fill out the last data block in the longer ones
            //     for (var j = longerBlocksStartAt; j < numResultBlocks; j++) {
            //         result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++];
            //     }
            //     // Now add in error correction blocks
            //     var max = result[0].codewords.length;
            //     for (var i = shorterBlocksNumDataCodewords; i < max; i++) {
            //         for (var j = 0; j < numResultBlocks; j++) {
            //             var iOffset = j < longerBlocksStartAt ? i : i + 1;
            //             result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
            //         }
            //     }
            //     return result;
            // }

            // //bmparser.js
            // function BitMatrixParser(bitMatrix) {
            //     var dimension = bitMatrix.Dimension;
            //     if (dimension < 21 || (dimension & 0x03) != 1) {
            //         throw "Error BitMatrixParser";
            //     }
            //     this.bitMatrix = bitMatrix;
            //     this.parsedVersion = null;
            //     this.parsedFormatInfo = null;

            //     this.copyBit = function (i, j, versionBits) {
            //         return this.bitMatrix.get_Renamed(i, j) ? (versionBits << 1) | 0x1 : versionBits << 1;
            //     }

            //     this.readFormatInformation = function () {
            //         if (this.parsedFormatInfo != null) {
            //             return this.parsedFormatInfo;
            //         }

            //         // Read top-left format info bits
            //         var formatInfoBits = 0;
            //         for (var i = 0; i < 6; i++) {
            //             formatInfoBits = this.copyBit(i, 8, formatInfoBits);
            //         }
            //         // .. and skip a bit in the timing pattern ...
            //         formatInfoBits = this.copyBit(7, 8, formatInfoBits);
            //         formatInfoBits = this.copyBit(8, 8, formatInfoBits);
            //         formatInfoBits = this.copyBit(8, 7, formatInfoBits);
            //         // .. and skip a bit in the timing pattern ...
            //         for (var j = 5; j >= 0; j--) {
            //             formatInfoBits = this.copyBit(8, j, formatInfoBits);
            //         }

            //         this.parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits);
            //         if (this.parsedFormatInfo != null) {
            //             return this.parsedFormatInfo;
            //         }

            //         // Hmm, failed. Try the top-right/bottom-left pattern
            //         var dimension = this.bitMatrix.Dimension;
            //         formatInfoBits = 0;
            //         var iMin = dimension - 8;
            //         for (var i = dimension - 1; i >= iMin; i--) {
            //             formatInfoBits = this.copyBit(i, 8, formatInfoBits);
            //         }
            //         for (var j = dimension - 7; j < dimension; j++) {
            //             formatInfoBits = this.copyBit(8, j, formatInfoBits);
            //         }

            //         this.parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits);
            //         if (this.parsedFormatInfo != null) {
            //             return this.parsedFormatInfo;
            //         }
            //         throw "Error readFormatInformation";
            //     }
            //     this.readVersion = function () {

            //         if (this.parsedVersion != null) {
            //             return this.parsedVersion;
            //         }

            //         var dimension = this.bitMatrix.Dimension;

            //         var provisionalVersion = (dimension - 17) >> 2;
            //         if (provisionalVersion <= 6) {
            //             return Version.getVersionForNumber(provisionalVersion);
            //         }

            //         // Read top-right version info: 3 wide by 6 tall
            //         var versionBits = 0;
            //         var ijMin = dimension - 11;
            //         for (var j = 5; j >= 0; j--) {
            //             for (var i = dimension - 9; i >= ijMin; i--) {
            //                 versionBits = this.copyBit(i, j, versionBits);
            //             }
            //         }

            //         this.parsedVersion = Version.decodeVersionInformation(versionBits);
            //         if (this.parsedVersion != null && this.parsedVersion.DimensionForVersion == dimension) {
            //             return this.parsedVersion;
            //         }

            //         // Hmm, failed. Try bottom left: 6 wide by 3 tall
            //         versionBits = 0;
            //         for (var i = 5; i >= 0; i--) {
            //             for (var j = dimension - 9; j >= ijMin; j--) {
            //                 versionBits = this.copyBit(i, j, versionBits);
            //             }
            //         }

            //         this.parsedVersion = Version.decodeVersionInformation(versionBits);
            //         if (this.parsedVersion != null && this.parsedVersion.DimensionForVersion == dimension) {
            //             return this.parsedVersion;
            //         }
            //         throw "Error readVersion";
            //     }
            //     this.readCodewords = function () {

            //         var formatInfo = this.readFormatInformation();
            //         var version = this.readVersion();

            //         // Get the data mask for the format used in this QR Code. This will exclude
            //         // some bits from reading as we wind through the bit matrix.
            //         var dataMask = DataMask.forReference(formatInfo.DataMask);
            //         var dimension = this.bitMatrix.Dimension;
            //         dataMask.unmaskBitMatrix(this.bitMatrix, dimension);

            //         var functionPattern = version.buildFunctionPattern();

            //         var readingUp = true;
            //         var result = new Array(version.TotalCodewords);
            //         var resultOffset = 0;
            //         var currentByte = 0;
            //         var bitsRead = 0;
            //         // Read columns in pairs, from right to left
            //         for (var j = dimension - 1; j > 0; j -= 2) {
            //             if (j == 6) {
            //                 // Skip whole column with vertical alignment pattern;
            //                 // saves time and makes the other code proceed more cleanly
            //                 j--;
            //             }
            //             // Read alternatingly from bottom to top then top to bottom
            //             for (var count = 0; count < dimension; count++) {
            //                 var i = readingUp ? dimension - 1 - count : count;
            //                 for (var col = 0; col < 2; col++) {
            //                     // Ignore bits covered by the function pattern
            //                     if (!functionPattern.get_Renamed(j - col, i)) {
            //                         // Read a bit
            //                         bitsRead++;
            //                         currentByte <<= 1;
            //                         if (this.bitMatrix.get_Renamed(j - col, i)) {
            //                             currentByte |= 1;
            //                         }
            //                         // If we've made a whole byte, save it off
            //                         if (bitsRead == 8) {
            //                             result[resultOffset++] = currentByte;
            //                             bitsRead = 0;
            //                             currentByte = 0;
            //                         }
            //                     }
            //                 }
            //             }
            //             readingUp ^= true; // readingUp = !readingUp; // switch directions
            //         }
            //         if (resultOffset != version.TotalCodewords) {
            //             throw "Error readCodewords";
            //         }
            //         return result;
            //     }
            // }

            // //datamask.js
            // var DataMask = {};

            // DataMask.forReference = function (reference) {
            //     if (reference < 0 || reference > 7) {
            //         throw "System.ArgumentException";
            //     }
            //     return DataMask.DATA_MASKS[reference];
            // }

            // function DataMask000() {
            //     this.unmaskBitMatrix = function (bits, dimension) {
            //         for (var i = 0; i < dimension; i++) {
            //             for (var j = 0; j < dimension; j++) {
            //                 if (this.isMasked(i, j)) {
            //                     bits.flip(j, i);
            //                 }
            //             }
            //         }
            //     }
            //     this.isMasked = function (i, j) {
            //         return ((i + j) & 0x01) == 0;
            //     }
            // }

            // function DataMask001() {
            //     this.unmaskBitMatrix = function (bits, dimension) {
            //         for (var i = 0; i < dimension; i++) {
            //             for (var j = 0; j < dimension; j++) {
            //                 if (this.isMasked(i, j)) {
            //                     bits.flip(j, i);
            //                 }
            //             }
            //         }
            //     }
            //     this.isMasked = function (i, j) {
            //         return (i & 0x01) == 0;
            //     }
            // }

            // function DataMask010() {
            //     this.unmaskBitMatrix = function (bits, dimension) {
            //         for (var i = 0; i < dimension; i++) {
            //             for (var j = 0; j < dimension; j++) {
            //                 if (this.isMasked(i, j)) {
            //                     bits.flip(j, i);
            //                 }
            //             }
            //         }
            //     }
            //     this.isMasked = function (i, j) {
            //         return j % 3 == 0;
            //     }
            // }

            // function DataMask011() {
            //     this.unmaskBitMatrix = function (bits, dimension) {
            //         for (var i = 0; i < dimension; i++) {
            //             for (var j = 0; j < dimension; j++) {
            //                 if (this.isMasked(i, j)) {
            //                     bits.flip(j, i);
            //                 }
            //             }
            //         }
            //     }
            //     this.isMasked = function (i, j) {
            //         return (i + j) % 3 == 0;
            //     }
            // }

            // function DataMask100() {
            //     this.unmaskBitMatrix = function (bits, dimension) {
            //         for (var i = 0; i < dimension; i++) {
            //             for (var j = 0; j < dimension; j++) {
            //                 if (this.isMasked(i, j)) {
            //                     bits.flip(j, i);
            //                 }
            //             }
            //         }
            //     }
            //     this.isMasked = function (i, j) {
            //         return (((URShift(i, 1)) + (j / 3)) & 0x01) == 0;
            //     }
            // }

            // function DataMask101() {
            //     this.unmaskBitMatrix = function (bits, dimension) {
            //         for (var i = 0; i < dimension; i++) {
            //             for (var j = 0; j < dimension; j++) {
            //                 if (this.isMasked(i, j)) {
            //                     bits.flip(j, i);
            //                 }
            //             }
            //         }
            //     }
            //     this.isMasked = function (i, j) {
            //         var temp = i * j;
            //         return (temp & 0x01) + (temp % 3) == 0;
            //     }
            // }

            // function DataMask110() {
            //     this.unmaskBitMatrix = function (bits, dimension) {
            //         for (var i = 0; i < dimension; i++) {
            //             for (var j = 0; j < dimension; j++) {
            //                 if (this.isMasked(i, j)) {
            //                     bits.flip(j, i);
            //                 }
            //             }
            //         }
            //     }
            //     this.isMasked = function (i, j) {
            //         var temp = i * j;
            //         return (((temp & 0x01) + (temp % 3)) & 0x01) == 0;
            //     }
            // }
            // function DataMask111() {
            //     this.unmaskBitMatrix = function (bits, dimension) {
            //         for (var i = 0; i < dimension; i++) {
            //             for (var j = 0; j < dimension; j++) {
            //                 if (this.isMasked(i, j)) {
            //                     bits.flip(j, i);
            //                 }
            //             }
            //         }
            //     }
            //     this.isMasked = function (i, j) {
            //         return ((((i + j) & 0x01) + ((i * j) % 3)) & 0x01) == 0;
            //     }
            // }

            // DataMask.DATA_MASKS = new Array(new DataMask000(), new DataMask001(), new DataMask010(), new DataMask011(), new DataMask100(), new DataMask101(), new DataMask110(), new DataMask111());

            // //rsdecoder.js
            // function ReedSolomonDecoder(field) {
            //     this.field = field;
            //     this.decode = function (received, twoS) {
            //         var poly = new GF256Poly(this.field, received);
            //         var syndromeCoefficients = new Array(twoS);
            //         for (var i = 0; i < syndromeCoefficients.length; i++)syndromeCoefficients[i] = 0;
            //         var dataMatrix = false;//this.field.Equals(GF256.DATA_MATRIX_FIELD);
            //         var noError = true;
            //         for (var i = 0; i < twoS; i++) {
            //             // Thanks to sanfordsquires for this fix:
            //             var evalu = poly.evaluateAt(this.field.exp(dataMatrix ? i + 1 : i));
            //             syndromeCoefficients[syndromeCoefficients.length - 1 - i] = evalu;
            //             if (evalu != 0) {
            //                 noError = false;
            //             }
            //         }
            //         if (noError) {
            //             return;
            //         }
            //         var syndrome = new GF256Poly(this.field, syndromeCoefficients);
            //         var sigmaOmega = this.runEuclideanAlgorithm(this.field.buildMonomial(twoS, 1), syndrome, twoS);
            //         var sigma = sigmaOmega[0];
            //         var omega = sigmaOmega[1];
            //         var errorLocations = this.findErrorLocations(sigma);
            //         var errorMagnitudes = this.findErrorMagnitudes(omega, errorLocations, dataMatrix);
            //         for (var i = 0; i < errorLocations.length; i++) {
            //             var position = received.length - 1 - this.field.log(errorLocations[i]);
            //             if (position < 0) {
            //                 throw "ReedSolomonException Bad error location";
            //             }
            //             received[position] = GF256.addOrSubtract(received[position], errorMagnitudes[i]);
            //         }
            //     }

            //     this.runEuclideanAlgorithm = function (a, b, R) {
            //         // Assume a's degree is >= b's
            //         if (a.Degree < b.Degree) {
            //             var temp = a;
            //             a = b;
            //             b = temp;
            //         }

            //         var rLast = a;
            //         var r = b;
            //         var sLast = this.field.One;
            //         var s = this.field.Zero;
            //         var tLast = this.field.Zero;
            //         var t = this.field.One;

            //         // Run Euclidean algorithm until r's degree is less than R/2
            //         while (r.Degree >= Math.floor(R / 2)) {
            //             var rLastLast = rLast;
            //             var sLastLast = sLast;
            //             var tLastLast = tLast;
            //             rLast = r;
            //             sLast = s;
            //             tLast = t;

            //             // Divide rLastLast by rLast, with quotient in q and remainder in r
            //             if (rLast.Zero) {
            //                 // Oops, Euclidean algorithm already terminated?
            //                 throw "r_{i-1} was zero";
            //             }
            //             r = rLastLast;
            //             var q = this.field.Zero;
            //             var denominatorLeadingTerm = rLast.getCoefficient(rLast.Degree);
            //             var dltInverse = this.field.inverse(denominatorLeadingTerm);
            //             while (r.Degree >= rLast.Degree && !r.Zero) {
            //                 var degreeDiff = r.Degree - rLast.Degree;
            //                 var scale = this.field.multiply(r.getCoefficient(r.Degree), dltInverse);
            //                 q = q.addOrSubtract(this.field.buildMonomial(degreeDiff, scale));
            //                 r = r.addOrSubtract(rLast.multiplyByMonomial(degreeDiff, scale));
            //                 //r.EXE();
            //             }

            //             s = q.multiply1(sLast).addOrSubtract(sLastLast);
            //             t = q.multiply1(tLast).addOrSubtract(tLastLast);
            //         }

            //         var sigmaTildeAtZero = t.getCoefficient(0);
            //         if (sigmaTildeAtZero == 0) {
            //             throw "ReedSolomonException sigmaTilde(0) was zero";
            //         }

            //         var inverse = this.field.inverse(sigmaTildeAtZero);
            //         var sigma = t.multiply2(inverse);
            //         var omega = r.multiply2(inverse);
            //         return new Array(sigma, omega);
            //     }
            //     this.findErrorLocations = function (errorLocator) {
            //         // This is a direct application of Chien's search
            //         var numErrors = errorLocator.Degree;
            //         if (numErrors == 1) {
            //             // shortcut
            //             return new Array(errorLocator.getCoefficient(1));
            //         }
            //         var result = new Array(numErrors);
            //         var e = 0;
            //         for (var i = 1; i < 256 && e < numErrors; i++) {
            //             if (errorLocator.evaluateAt(i) == 0) {
            //                 result[e] = this.field.inverse(i);
            //                 e++;
            //             }
            //         }
            //         if (e != numErrors) {
            //             throw "Error locator degree does not match number of roots";
            //         }
            //         return result;
            //     }
            //     this.findErrorMagnitudes = function (errorEvaluator, errorLocations, dataMatrix) {
            //         // This is directly applying Forney's Formula
            //         var s = errorLocations.length;
            //         var result = new Array(s);
            //         for (var i = 0; i < s; i++) {
            //             var xiInverse = this.field.inverse(errorLocations[i]);
            //             var denominator = 1;
            //             for (var j = 0; j < s; j++) {
            //                 if (i != j) {
            //                     denominator = this.field.multiply(denominator, GF256.addOrSubtract(1, this.field.multiply(errorLocations[j], xiInverse)));
            //                 }
            //             }
            //             result[i] = this.field.multiply(errorEvaluator.evaluateAt(xiInverse), this.field.inverse(denominator));
            //             // Thanks to sanfordsquires for this fix:
            //             if (dataMatrix) {
            //                 result[i] = this.field.multiply(result[i], xiInverse);
            //             }
            //         }
            //         return result;
            //     }
            // }

            // //gf256poly.js
            // function GF256Poly(field, coefficients) {
            //     if (coefficients == null || coefficients.length == 0) {
            //         throw "System.ArgumentException";
            //     }
            //     this.field = field;
            //     var coefficientsLength = coefficients.length;
            //     if (coefficientsLength > 1 && coefficients[0] == 0) {
            //         // Leading term must be non-zero for anything except the constant polynomial "0"
            //         var firstNonZero = 1;
            //         while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0) {
            //             firstNonZero++;
            //         }
            //         if (firstNonZero == coefficientsLength) {
            //             this.coefficients = field.Zero.coefficients;
            //         }
            //         else {
            //             this.coefficients = new Array(coefficientsLength - firstNonZero);
            //             for (var i = 0; i < this.coefficients.length; i++)this.coefficients[i] = 0;
            //             //Array.Copy(coefficients, firstNonZero, this.coefficients, 0, this.coefficients.length);
            //             for (var ci = 0; ci < this.coefficients.length; ci++)this.coefficients[ci] = coefficients[firstNonZero + ci];
            //         }
            //     }
            //     else {
            //         this.coefficients = coefficients;
            //     }

            //     this.__defineGetter__("Zero", function () {
            //         return this.coefficients[0] == 0;
            //     });
            //     this.__defineGetter__("Degree", function () {
            //         return this.coefficients.length - 1;
            //     });
            //     this.__defineGetter__("Coefficients", function () {
            //         return this.coefficients;
            //     });

            //     this.getCoefficient = function (degree) {
            //         return this.coefficients[this.coefficients.length - 1 - degree];
            //     }

            //     this.evaluateAt = function (a) {
            //         if (a == 0) {
            //             // Just return the x^0 coefficient
            //             return this.getCoefficient(0);
            //         }
            //         var size = this.coefficients.length;
            //         if (a == 1) {
            //             // Just the sum of the coefficients
            //             var result = 0;
            //             for (var i = 0; i < size; i++) {
            //                 result = GF256.addOrSubtract(result, this.coefficients[i]);
            //             }
            //             return result;
            //         }
            //         var result2 = this.coefficients[0];
            //         for (var i = 1; i < size; i++) {
            //             result2 = GF256.addOrSubtract(this.field.multiply(a, result2), this.coefficients[i]);
            //         }
            //         return result2;
            //     }

            //     this.addOrSubtract = function (other) {
            //         if (this.field != other.field) {
            //             throw "GF256Polys do not have same GF256 field";
            //         }
            //         if (this.Zero) {
            //             return other;
            //         }
            //         if (other.Zero) {
            //             return this;
            //         }

            //         var smallerCoefficients = this.coefficients;
            //         var largerCoefficients = other.coefficients;
            //         if (smallerCoefficients.length > largerCoefficients.length) {
            //             var temp = smallerCoefficients;
            //             smallerCoefficients = largerCoefficients;
            //             largerCoefficients = temp;
            //         }
            //         var sumDiff = new Array(largerCoefficients.length);
            //         var lengthDiff = largerCoefficients.length - smallerCoefficients.length;
            //         // Copy high-order terms only found in higher-degree polynomial's coefficients
            //         //Array.Copy(largerCoefficients, 0, sumDiff, 0, lengthDiff);
            //         for (var ci = 0; ci < lengthDiff; ci++)sumDiff[ci] = largerCoefficients[ci];

            //         for (var i = lengthDiff; i < largerCoefficients.length; i++) {
            //             sumDiff[i] = GF256.addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]);
            //         }

            //         return new GF256Poly(field, sumDiff);
            //     }
            //     this.multiply1 = function (other) {
            //         if (this.field != other.field) {
            //             throw "GF256Polys do not have same GF256 field";
            //         }
            //         if (this.Zero || other.Zero) {
            //             return this.field.Zero;
            //         }
            //         var aCoefficients = this.coefficients;
            //         var aLength = aCoefficients.length;
            //         var bCoefficients = other.coefficients;
            //         var bLength = bCoefficients.length;
            //         var product = new Array(aLength + bLength - 1);
            //         for (var i = 0; i < aLength; i++) {
            //             var aCoeff = aCoefficients[i];
            //             for (var j = 0; j < bLength; j++) {
            //                 product[i + j] = GF256.addOrSubtract(product[i + j], this.field.multiply(aCoeff, bCoefficients[j]));
            //             }
            //         }
            //         return new GF256Poly(this.field, product);
            //     }
            //     this.multiply2 = function (scalar) {
            //         if (scalar == 0) {
            //             return this.field.Zero;
            //         }
            //         if (scalar == 1) {
            //             return this;
            //         }
            //         var size = this.coefficients.length;
            //         var product = new Array(size);
            //         for (var i = 0; i < size; i++) {
            //             product[i] = this.field.multiply(this.coefficients[i], scalar);
            //         }
            //         return new GF256Poly(this.field, product);
            //     }
            //     this.multiplyByMonomial = function (degree, coefficient) {
            //         if (degree < 0) {
            //             throw "System.ArgumentException";
            //         }
            //         if (coefficient == 0) {
            //             return this.field.Zero;
            //         }
            //         var size = this.coefficients.length;
            //         var product = new Array(size + degree);
            //         for (var i = 0; i < product.length; i++)product[i] = 0;
            //         for (var i = 0; i < size; i++) {
            //             product[i] = this.field.multiply(this.coefficients[i], coefficient);
            //         }
            //         return new GF256Poly(this.field, product);
            //     }
            //     this.divide = function (other) {
            //         if (this.field != other.field) {
            //             throw "GF256Polys do not have same GF256 field";
            //         }
            //         if (other.Zero) {
            //             throw "Divide by 0";
            //         }

            //         var quotient = this.field.Zero;
            //         var remainder = this;

            //         var denominatorLeadingTerm = other.getCoefficient(other.Degree);
            //         var inverseDenominatorLeadingTerm = this.field.inverse(denominatorLeadingTerm);

            //         while (remainder.Degree >= other.Degree && !remainder.Zero) {
            //             var degreeDifference = remainder.Degree - other.Degree;
            //             var scale = this.field.multiply(remainder.getCoefficient(remainder.Degree), inverseDenominatorLeadingTerm);
            //             var term = other.multiplyByMonomial(degreeDifference, scale);
            //             var iterationQuotient = this.field.buildMonomial(degreeDifference, scale);
            //             quotient = quotient.addOrSubtract(iterationQuotient);
            //             remainder = remainder.addOrSubtract(term);
            //         }

            //         return new Array(quotient, remainder);
            //     }
            // }

            // //gf256.js
            // function GF256(primitive) {
            //     this.expTable = new Array(256);
            //     this.logTable = new Array(256);
            //     var x = 1;
            //     for (var i = 0; i < 256; i++) {
            //         this.expTable[i] = x;
            //         x <<= 1; // x = x * 2; we're assuming the generator alpha is 2
            //         if (x >= 0x100) {
            //             x ^= primitive;
            //         }
            //     }
            //     for (var i = 0; i < 255; i++) {
            //         this.logTable[this.expTable[i]] = i;
            //     }
            //     // logTable[0] == 0 but this should never be used
            //     var at0 = new Array(1); at0[0] = 0;
            //     this.zero = new GF256Poly(this, new Array(at0));
            //     var at1 = new Array(1); at1[0] = 1;
            //     this.one = new GF256Poly(this, new Array(at1));

            //     this.__defineGetter__("Zero", function () {
            //         return this.zero;
            //     });
            //     this.__defineGetter__("One", function () {
            //         return this.one;
            //     });
            //     this.buildMonomial = function (degree, coefficient) {
            //         if (degree < 0) {
            //             throw "System.ArgumentException";
            //         }
            //         if (coefficient == 0) {
            //             return this.zero;
            //         }
            //         var coefficients = new Array(degree + 1);
            //         for (var i = 0; i < coefficients.length; i++)coefficients[i] = 0;
            //         coefficients[0] = coefficient;
            //         return new GF256Poly(this, coefficients);
            //     }
            //     this.exp = function (a) {
            //         return this.expTable[a];
            //     }
            //     this.log = function (a) {
            //         if (a == 0) {
            //             throw "System.ArgumentException";
            //         }
            //         return this.logTable[a];
            //     }
            //     this.inverse = function (a) {
            //         if (a == 0) {
            //             throw "System.ArithmeticException";
            //         }
            //         return this.expTable[255 - this.logTable[a]];
            //     }
            //     this.multiply = function (a, b) {
            //         if (a == 0 || b == 0) {
            //             return 0;
            //         }
            //         if (a == 1) {
            //             return b;
            //         }
            //         if (b == 1) {
            //             return a;
            //         }
            //         return this.expTable[(this.logTable[a] + this.logTable[b]) % 255];
            //     }
            // }

            // GF256.QR_CODE_FIELD = new GF256(0x011D);
            // GF256.DATA_MATRIX_FIELD = new GF256(0x012D);

            // GF256.addOrSubtract = function (a, b) {
            //     return a ^ b;
            // }


            // //decoder.js
            // var Decoder = {};
            // Decoder.rsDecoder = new ReedSolomonDecoder(GF256.QR_CODE_FIELD);

            // Decoder.correctErrors = function (codewordBytes, numDataCodewords) {
            //     var numCodewords = codewordBytes.length;
            //     // First read into an array of ints
            //     var codewordsInts = new Array(numCodewords);
            //     for (var i = 0; i < numCodewords; i++) {
            //         codewordsInts[i] = codewordBytes[i] & 0xFF;
            //     }
            //     var numECCodewords = codewordBytes.length - numDataCodewords;
            //     try {
            //         Decoder.rsDecoder.decode(codewordsInts, numECCodewords);
            //         //var corrector = new ReedSolomon(codewordsInts, numECCodewords);
            //         //corrector.correct();
            //     }
            //     catch (rse) {
            //         throw rse;
            //     }
            //     // Copy back into array of bytes -- only need to worry about the bytes that were data
            //     // We don't care about errors in the error-correction codewords
            //     for (var i = 0; i < numDataCodewords; i++) {
            //         codewordBytes[i] = codewordsInts[i];
            //     }
            // }

            // Decoder.decode = function (bits) {
            //     var parser = new BitMatrixParser(bits);
            //     var version = parser.readVersion();
            //     var ecLevel = parser.readFormatInformation().ErrorCorrectionLevel;

            //     // Read codewords
            //     var codewords = parser.readCodewords();

            //     // Separate into data blocks
            //     var dataBlocks = DataBlock.getDataBlocks(codewords, version, ecLevel);

            //     // Count total number of data bytes
            //     var totalBytes = 0;
            //     for (var i = 0; i < dataBlocks.length; i++) {
            //         totalBytes += dataBlocks[i].NumDataCodewords;
            //     }
            //     var resultBytes = new Array(totalBytes);
            //     var resultOffset = 0;

            //     // Error-correct and copy data blocks together into a stream of bytes
            //     for (var j = 0; j < dataBlocks.length; j++) {
            //         var dataBlock = dataBlocks[j];
            //         var codewordBytes = dataBlock.Codewords;
            //         var numDataCodewords = dataBlock.NumDataCodewords;
            //         Decoder.correctErrors(codewordBytes, numDataCodewords);
            //         for (var i = 0; i < numDataCodewords; i++) {
            //             resultBytes[resultOffset++] = codewordBytes[i];
            //         }
            //     }

            //     // Decode the contents of that stream of bytes
            //     var reader = new QRCodeDataBlockReader(resultBytes, version.VersionNumber, ecLevel.Bits);
            //     return reader;
            //     //return DecodedBitStreamParser.decode(resultBytes, version, ecLevel);
            // }


            // //qrcode.js
            // var qrcode = {};
            // this.qrcode = qrcode
            // qrcode.imagedata = null;
            // qrcode.width = 0;
            // qrcode.height = 0;
            // qrcode.qrCodeSymbol = null;
            // qrcode.debug = false;
            // qrcode.maxImgSize = 1024 * 1024;
            // qrcode.sizeOfDataLengthInfo = [[10, 9, 8, 8], [12, 11, 16, 10], [14, 13, 16, 12]];
            // qrcode.callback = null;
            // qrcode.vidSuccess = function (stream) {
            //     qrcode.localstream = stream;
            //     if (qrcode.webkit)
            //         qrcode.video.src = window.webkitURL.createObjectURL(stream);
            //     else
            //         if (qrcode.moz) {
            //             qrcode.video.mozSrcObject = stream;
            //             qrcode.video.play();
            //         }
            //         else
            //             qrcode.video.src = stream;

            //     qrcode.gUM = true;

            //     qrcode.canvas_qr2 = document.createElement('canvas');
            //     qrcode.canvas_qr2.id = "qr-canvas";
            //     qrcode.qrcontext2 = qrcode.canvas_qr2.getContext('2d');
            //     qrcode.canvas_qr2.width = qrcode.video.videoWidth;
            //     qrcode.canvas_qr2.height = qrcode.video.videoHeight;
            //     setTimeout(qrcode.captureToCanvas, 500);
            // }
            // qrcode.vidError = function (error) {
            //     qrcode.gUM = false;
            //     return;
            // }
            // qrcode.captureToCanvas = function () {
            //     if (qrcode.gUM) {
            //         try {
            //             if (qrcode.video.videoWidth == 0) {
            //                 setTimeout(qrcode.captureToCanvas, 500);
            //                 return;
            //             }
            //             else {
            //                 qrcode.canvas_qr2.width = qrcode.video.videoWidth;
            //                 qrcode.canvas_qr2.height = qrcode.video.videoHeight;
            //             }
            //             qrcode.qrcontext2.drawImage(qrcode.video, 0, 0);
            //             try {
            //                 qrcode.decode();
            //             }
            //             catch (e) {
            //                 console.log(e);
            //                 setTimeout(qrcode.captureToCanvas, 500);
            //             };
            //         }
            //         catch (e) {
            //             console.log(e);
            //             setTimeout(qrcode.captureToCanvas, 500);
            //         };
            //     }
            // }
            // qrcode.setWebcam = function (videoId) {
            //     var n = navigator;
            //     qrcode.video = document.getElementById(videoId);

            //     var options = true;
            //     if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
            //         try {
            //             navigator.mediaDevices.enumerateDevices()
            //                 .then(function (devices) {
            //                     devices.forEach(function (device) {
            //                         console.log("deb1");
            //                         if (device.kind === 'videoinput') {
            //                             if (device.label.toLowerCase().search("back") > -1)
            //                                 options = [{ 'sourceId': device.deviceId }];
            //                         }
            //                         console.log(device.kind + ": " + device.label +
            //                             " id = " + device.deviceId);
            //                     });
            //                 })

            //         }
            //         catch (e) {
            //             console.log(e);
            //         }
            //     }
            //     else {
            //         console.log("no navigator.mediaDevices.enumerateDevices");
            //     }

            //     if (n.getUserMedia)
            //         n.getUserMedia({ video: options, audio: false }, qrcode.vidSuccess, qrcode.vidError);
            //     else
            //         if (n.webkitGetUserMedia) {
            //             qrcode.webkit = true;
            //             n.webkitGetUserMedia({ video: options, audio: false }, qrcode.vidSuccess, qrcode.vidError);
            //         }
            //         else
            //             if (n.mozGetUserMedia) {
            //                 qrcode.moz = true;
            //                 n.mozGetUserMedia({ video: options, audio: false }, qrcode.vidSuccess, qrcode.vidError);
            //             }
            // }
            // qrcode.decode = function (src) {

            //     if (arguments.length == 0) {
            //         if (qrcode.canvas_qr2) {
            //             var canvas_qr = qrcode.canvas_qr2;
            //             var context = qrcode.qrcontext2;
            //         }
            //         else {
            //             var canvas_qr = document.getElementById("qr-canvas");
            //             var context = canvas_qr.getContext('2d');
            //         }
            //         qrcode.width = canvas_qr.width;
            //         qrcode.height = canvas_qr.height;
            //         qrcode.imagedata = context.getImageData(0, 0, qrcode.width, qrcode.height);
            //         qrcode.result = qrcode.process(context);
            //         if (qrcode.callback != null)
            //             qrcode.callback(qrcode.result);
            //         return qrcode.result;
            //     }
            //     else {
            //         var image = new Image();
            //         image.crossOrigin = "Anonymous";
            //         image.onload = function () {
            //             //var canvas_qr = document.getElementById("qr-canvas");
            //             var canvas_out = document.getElementById("out-canvas");
            //             if (canvas_out != null) {
            //                 var outctx = canvas_out.getContext('2d');
            //                 outctx.clearRect(0, 0, 320, 240);
            //                 outctx.drawImage(image, 0, 0, 320, 240);
            //             }

            //             var canvas_qr = document.createElement('canvas');
            //             var context = canvas_qr.getContext('2d');
            //             var nheight = image.height;
            //             var nwidth = image.width;
            //             if (image.width * image.height > qrcode.maxImgSize) {
            //                 var ir = image.width / image.height;
            //                 nheight = Math.sqrt(qrcode.maxImgSize / ir);
            //                 nwidth = ir * nheight;
            //             }

            //             canvas_qr.width = nwidth;
            //             canvas_qr.height = nheight;

            //             context.drawImage(image, 0, 0, canvas_qr.width, canvas_qr.height);
            //             qrcode.width = canvas_qr.width;
            //             qrcode.height = canvas_qr.height;
            //             try {
            //                 qrcode.imagedata = context.getImageData(0, 0, canvas_qr.width, canvas_qr.height);
            //             } catch (e) {
            //                 qrcode.result = "Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!";
            //                 if (qrcode.callback != null)
            //                     qrcode.callback(qrcode.result);
            //                 return;
            //             }

            //             try {
            //                 qrcode.result = qrcode.process(context);
            //             }
            //             catch (e) {
            //                 console.log(e);
            //                 qrcode.result = "error decoding QR Code";
            //             }
            //             if (qrcode.callback != null)
            //                 qrcode.callback(qrcode.result);
            //         }
            //         image.onerror = function () {
            //             if (qrcode.callback != null)
            //                 qrcode.callback("Failed to load the image");
            //         }
            //         image.src = src;
            //     }
            // }
            // qrcode.isUrl = function (s) {
            //     var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
            //     return regexp.test(s);
            // }
            // qrcode.decode_url = function (s) {
            //     var escaped = "";
            //     try {
            //         escaped = escape(s);
            //     }
            //     catch (e) {
            //         console.log(e);
            //         escaped = s;
            //     }
            //     var ret = "";
            //     try {
            //         ret = decodeURIComponent(escaped);
            //     }
            //     catch (e) {
            //         console.log(e);
            //         ret = escaped;
            //     }
            //     return ret;
            // }
            // qrcode.decode_utf8 = function (s) {
            //     if (qrcode.isUrl(s))
            //         return qrcode.decode_url(s);
            //     else
            //         return s;
            // }
            // qrcode.process = function (ctx) {

            //     var start = new Date().getTime();

            //     var image = qrcode.grayScaleToBitmap(qrcode.grayscale());
            //     //var image = qrcode.binarize(128);

            //     if (qrcode.debug) {
            //         for (var y = 0; y < qrcode.height; y++) {
            //             for (var x = 0; x < qrcode.width; x++) {
            //                 var point = (x * 4) + (y * qrcode.width * 4);
            //                 qrcode.imagedata.data[point] = image[x + y * qrcode.width] ? 0 : 0;
            //                 qrcode.imagedata.data[point + 1] = image[x + y * qrcode.width] ? 0 : 0;
            //                 qrcode.imagedata.data[point + 2] = image[x + y * qrcode.width] ? 255 : 0;
            //             }
            //         }
            //         ctx.putImageData(qrcode.imagedata, 0, 0);
            //     }

            //     //var finderPatternInfo = new FinderPatternFinder().findFinderPattern(image);

            //     var detector = new Detector(image);

            //     var qRCodeMatrix = detector.detect();

            //     if (qrcode.debug) {
            //         for (var y = 0; y < qRCodeMatrix.bits.Height; y++) {
            //             for (var x = 0; x < qRCodeMatrix.bits.Width; x++) {
            //                 var point = (x * 4 * 2) + (y * 2 * qrcode.width * 4);
            //                 qrcode.imagedata.data[point] = qRCodeMatrix.bits.get_Renamed(x, y) ? 0 : 0;
            //                 qrcode.imagedata.data[point + 1] = qRCodeMatrix.bits.get_Renamed(x, y) ? 0 : 0;
            //                 qrcode.imagedata.data[point + 2] = qRCodeMatrix.bits.get_Renamed(x, y) ? 255 : 0;
            //             }
            //         }
            //         ctx.putImageData(qrcode.imagedata, 0, 0);
            //     }


            //     var reader = Decoder.decode(qRCodeMatrix.bits);
            //     var data = reader.DataByte;
            //     var str = "";
            //     for (var i = 0; i < data.length; i++) {
            //         for (var j = 0; j < data[i].length; j++)
            //             str += String.fromCharCode(data[i][j]);
            //     }

            //     var end = new Date().getTime();
            //     var time = end - start;
            //     console.log(time);

            //     return qrcode.decode_utf8(str);
            //     //alert("Time:" + time + " Code: "+str);
            // }
            // qrcode.getPixel = function (x, y) {
            //     if (qrcode.width < x) {
            //         throw "point error";
            //     }
            //     if (qrcode.height < y) {
            //         throw "point error";
            //     }
            //     var point = (x * 4) + (y * qrcode.width * 4);
            //     var p = (qrcode.imagedata.data[point] * 33 + qrcode.imagedata.data[point + 1] * 34 + qrcode.imagedata.data[point + 2] * 33) / 100;
            //     return p;
            // }
            // qrcode.binarize = function (th) {
            //     var ret = new Array(qrcode.width * qrcode.height);
            //     for (var y = 0; y < qrcode.height; y++) {
            //         for (var x = 0; x < qrcode.width; x++) {
            //             var gray = qrcode.getPixel(x, y);

            //             ret[x + y * qrcode.width] = gray <= th ? true : false;
            //         }
            //     }
            //     return ret;
            // }
            // qrcode.getMiddleBrightnessPerArea = function (image) {
            //     var numSqrtArea = 4;
            //     //obtain middle brightness((min + max) / 2) per area
            //     var areaWidth = Math.floor(qrcode.width / numSqrtArea);
            //     var areaHeight = Math.floor(qrcode.height / numSqrtArea);
            //     var minmax = new Array(numSqrtArea);
            //     for (var i = 0; i < numSqrtArea; i++) {
            //         minmax[i] = new Array(numSqrtArea);
            //         for (var i2 = 0; i2 < numSqrtArea; i2++) {
            //             minmax[i][i2] = new Array(0, 0);
            //         }
            //     }
            //     for (var ay = 0; ay < numSqrtArea; ay++) {
            //         for (var ax = 0; ax < numSqrtArea; ax++) {
            //             minmax[ax][ay][0] = 0xFF;
            //             for (var dy = 0; dy < areaHeight; dy++) {
            //                 for (var dx = 0; dx < areaWidth; dx++) {
            //                     var target = image[areaWidth * ax + dx + (areaHeight * ay + dy) * qrcode.width];
            //                     if (target < minmax[ax][ay][0])
            //                         minmax[ax][ay][0] = target;
            //                     if (target > minmax[ax][ay][1])
            //                         minmax[ax][ay][1] = target;
            //                 }
            //             }
            //             //minmax[ax][ay][0] = (minmax[ax][ay][0] + minmax[ax][ay][1]) / 2;
            //         }
            //     }
            //     var middle = new Array(numSqrtArea);
            //     for (var i3 = 0; i3 < numSqrtArea; i3++) {
            //         middle[i3] = new Array(numSqrtArea);
            //     }
            //     for (var ay = 0; ay < numSqrtArea; ay++) {
            //         for (var ax = 0; ax < numSqrtArea; ax++) {
            //             middle[ax][ay] = Math.floor((minmax[ax][ay][0] + minmax[ax][ay][1]) / 2);
            //             //Console.out.print(middle[ax][ay] + ",");
            //         }
            //         //Console.out.println("");
            //     }
            //     //Console.out.println("");

            //     return middle;
            // }
            // qrcode.grayScaleToBitmap = function (grayScale) {
            //     var middle = qrcode.getMiddleBrightnessPerArea(grayScale);
            //     var sqrtNumArea = middle.length;
            //     var areaWidth = Math.floor(qrcode.width / sqrtNumArea);
            //     var areaHeight = Math.floor(qrcode.height / sqrtNumArea);

            //     var buff = new ArrayBuffer(qrcode.width * qrcode.height);
            //     var bitmap = new Uint8Array(buff);

            //     //var bitmap = new Array(qrcode.height*qrcode.width);

            //     for (var ay = 0; ay < sqrtNumArea; ay++) {
            //         for (var ax = 0; ax < sqrtNumArea; ax++) {
            //             for (var dy = 0; dy < areaHeight; dy++) {
            //                 for (var dx = 0; dx < areaWidth; dx++) {
            //                     bitmap[areaWidth * ax + dx + (areaHeight * ay + dy) * qrcode.width] = (grayScale[areaWidth * ax + dx + (areaHeight * ay + dy) * qrcode.width] < middle[ax][ay]) ? true : false;
            //                 }
            //             }
            //         }
            //     }
            //     return bitmap;
            // }
            // qrcode.grayscale = function () {
            //     var buff = new ArrayBuffer(qrcode.width * qrcode.height);
            //     var ret = new Uint8Array(buff);
            //     //var ret = new Array(qrcode.width*qrcode.height);

            //     for (var y = 0; y < qrcode.height; y++) {
            //         for (var x = 0; x < qrcode.width; x++) {
            //             var gray = qrcode.getPixel(x, y);

            //             ret[x + y * qrcode.width] = gray;
            //         }
            //     }
            //     return ret;
            // }
            // function URShift(number, bits) {
            //     if (number >= 0)
            //         return number >> bits;
            //     else
            //         return (number >> bits) + (2 << ~bits);
            // }


            // //findpat.js
            // var MIN_SKIP = 3;
            // var MAX_MODULES = 57;
            // var INTEGER_MATH_SHIFT = 8;
            // var CENTER_QUORUM = 2;
            // qrcode.orderBestPatterns = function (patterns) {

            //     function distance(pattern1, pattern2) {
            //         var xDiff = pattern1.X - pattern2.X;
            //         var yDiff = pattern1.Y - pattern2.Y;
            //         return Math.sqrt((xDiff * xDiff + yDiff * yDiff));
            //     }

            //     /// <summary> Returns the z component of the cross product between vectors BC and BA.</summary>
            //     function crossProductZ(pointA, pointB, pointC) {
            //         var bX = pointB.x;
            //         var bY = pointB.y;
            //         return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX));
            //     }


            //     // Find distances between pattern centers
            //     var zeroOneDistance = distance(patterns[0], patterns[1]);
            //     var oneTwoDistance = distance(patterns[1], patterns[2]);
            //     var zeroTwoDistance = distance(patterns[0], patterns[2]);

            //     var pointA, pointB, pointC;
            //     // Assume one closest to other two is B; A and C will just be guesses at first
            //     if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) {
            //         pointB = patterns[0];
            //         pointA = patterns[1];
            //         pointC = patterns[2];
            //     }
            //     else if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance) {
            //         pointB = patterns[1];
            //         pointA = patterns[0];
            //         pointC = patterns[2];
            //     }
            //     else {
            //         pointB = patterns[2];
            //         pointA = patterns[0];
            //         pointC = patterns[1];
            //     }

            //     // Use cross product to figure out whether A and C are correct or flipped.
            //     // This asks whether BC x BA has a positive z component, which is the arrangement
            //     // we want for A, B, C. If it's negative, then we've got it flipped around and
            //     // should swap A and C.
            //     if (crossProductZ(pointA, pointB, pointC) < 0.0) {
            //         var temp = pointA;
            //         pointA = pointC;
            //         pointC = temp;
            //     }

            //     patterns[0] = pointA;
            //     patterns[1] = pointB;
            //     patterns[2] = pointC;
            // }
            // function FinderPattern(posX, posY, estimatedModuleSize) {
            //     this.x = posX;
            //     this.y = posY;
            //     this.count = 1;
            //     this.estimatedModuleSize = estimatedModuleSize;

            //     this.__defineGetter__("EstimatedModuleSize", function () {
            //         return this.estimatedModuleSize;
            //     });
            //     this.__defineGetter__("Count", function () {
            //         return this.count;
            //     });
            //     this.__defineGetter__("X", function () {
            //         return this.x;
            //     });
            //     this.__defineGetter__("Y", function () {
            //         return this.y;
            //     });
            //     this.incrementCount = function () {
            //         this.count++;
            //     }
            //     this.aboutEquals = function (moduleSize, i, j) {
            //         if (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize) {
            //             var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);
            //             return moduleSizeDiff <= 1.0 || moduleSizeDiff / this.estimatedModuleSize <= 1.0;
            //         }
            //         return false;
            //     }

            // }
            // function FinderPatternInfo(patternCenters) {
            //     this.bottomLeft = patternCenters[0];
            //     this.topLeft = patternCenters[1];
            //     this.topRight = patternCenters[2];
            //     this.__defineGetter__("BottomLeft", function () {
            //         return this.bottomLeft;
            //     });
            //     this.__defineGetter__("TopLeft", function () {
            //         return this.topLeft;
            //     });
            //     this.__defineGetter__("TopRight", function () {
            //         return this.topRight;
            //     });
            // }
            // function FinderPatternFinder() {
            //     this.image = null;
            //     this.possibleCenters = [];
            //     this.hasSkipped = false;
            //     this.crossCheckStateCount = new Array(0, 0, 0, 0, 0);
            //     this.resultPointCallback = null;

            //     this.__defineGetter__("CrossCheckStateCount", function () {
            //         this.crossCheckStateCount[0] = 0;
            //         this.crossCheckStateCount[1] = 0;
            //         this.crossCheckStateCount[2] = 0;
            //         this.crossCheckStateCount[3] = 0;
            //         this.crossCheckStateCount[4] = 0;
            //         return this.crossCheckStateCount;
            //     });

            //     this.foundPatternCross = function (stateCount) {
            //         var totalModuleSize = 0;
            //         for (var i = 0; i < 5; i++) {
            //             var count = stateCount[i];
            //             if (count == 0) {
            //                 return false;
            //             }
            //             totalModuleSize += count;
            //         }
            //         if (totalModuleSize < 7) {
            //             return false;
            //         }
            //         var moduleSize = Math.floor((totalModuleSize << INTEGER_MATH_SHIFT) / 7);
            //         var maxVariance = Math.floor(moduleSize / 2);
            //         // Allow less than 50% variance from 1-1-3-1-1 proportions
            //         return Math.abs(moduleSize - (stateCount[0] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(moduleSize - (stateCount[1] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(3 * moduleSize - (stateCount[2] << INTEGER_MATH_SHIFT)) < 3 * maxVariance && Math.abs(moduleSize - (stateCount[3] << INTEGER_MATH_SHIFT)) < maxVariance && Math.abs(moduleSize - (stateCount[4] << INTEGER_MATH_SHIFT)) < maxVariance;
            //     }
            //     this.centerFromEnd = function (stateCount, end) {
            //         return (end - stateCount[4] - stateCount[3]) - stateCount[2] / 2.0;
            //     }
            //     this.crossCheckVertical = function (startI, centerJ, maxCount, originalStateCountTotal) {
            //         var image = this.image;

            //         var maxI = qrcode.height;
            //         var stateCount = this.CrossCheckStateCount;

            //         // Start counting up from center
            //         var i = startI;
            //         while (i >= 0 && image[centerJ + i * qrcode.width]) {
            //             stateCount[2]++;
            //             i--;
            //         }
            //         if (i < 0) {
            //             return NaN;
            //         }
            //         while (i >= 0 && !image[centerJ + i * qrcode.width] && stateCount[1] <= maxCount) {
            //             stateCount[1]++;
            //             i--;
            //         }
            //         // If already too many modules in this state or ran off the edge:
            //         if (i < 0 || stateCount[1] > maxCount) {
            //             return NaN;
            //         }
            //         while (i >= 0 && image[centerJ + i * qrcode.width] && stateCount[0] <= maxCount) {
            //             stateCount[0]++;
            //             i--;
            //         }
            //         if (stateCount[0] > maxCount) {
            //             return NaN;
            //         }

            //         // Now also count down from center
            //         i = startI + 1;
            //         while (i < maxI && image[centerJ + i * qrcode.width]) {
            //             stateCount[2]++;
            //             i++;
            //         }
            //         if (i == maxI) {
            //             return NaN;
            //         }
            //         while (i < maxI && !image[centerJ + i * qrcode.width] && stateCount[3] < maxCount) {
            //             stateCount[3]++;
            //             i++;
            //         }
            //         if (i == maxI || stateCount[3] >= maxCount) {
            //             return NaN;
            //         }
            //         while (i < maxI && image[centerJ + i * qrcode.width] && stateCount[4] < maxCount) {
            //             stateCount[4]++;
            //             i++;
            //         }
            //         if (stateCount[4] >= maxCount) {
            //             return NaN;
            //         }

            //         // If we found a finder-pattern-like section, but its size is more than 40% different than
            //         // the original, assume it's a false positive
            //         var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
            //         if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) {
            //             return NaN;
            //         }

            //         return this.foundPatternCross(stateCount) ? this.centerFromEnd(stateCount, i) : NaN;
            //     }
            //     this.crossCheckHorizontal = function (startJ, centerI, maxCount, originalStateCountTotal) {
            //         var image = this.image;

            //         var maxJ = qrcode.width;
            //         var stateCount = this.CrossCheckStateCount;

            //         var j = startJ;
            //         while (j >= 0 && image[j + centerI * qrcode.width]) {
            //             stateCount[2]++;
            //             j--;
            //         }
            //         if (j < 0) {
            //             return NaN;
            //         }
            //         while (j >= 0 && !image[j + centerI * qrcode.width] && stateCount[1] <= maxCount) {
            //             stateCount[1]++;
            //             j--;
            //         }
            //         if (j < 0 || stateCount[1] > maxCount) {
            //             return NaN;
            //         }
            //         while (j >= 0 && image[j + centerI * qrcode.width] && stateCount[0] <= maxCount) {
            //             stateCount[0]++;
            //             j--;
            //         }
            //         if (stateCount[0] > maxCount) {
            //             return NaN;
            //         }

            //         j = startJ + 1;
            //         while (j < maxJ && image[j + centerI * qrcode.width]) {
            //             stateCount[2]++;
            //             j++;
            //         }
            //         if (j == maxJ) {
            //             return NaN;
            //         }
            //         while (j < maxJ && !image[j + centerI * qrcode.width] && stateCount[3] < maxCount) {
            //             stateCount[3]++;
            //             j++;
            //         }
            //         if (j == maxJ || stateCount[3] >= maxCount) {
            //             return NaN;
            //         }
            //         while (j < maxJ && image[j + centerI * qrcode.width] && stateCount[4] < maxCount) {
            //             stateCount[4]++;
            //             j++;
            //         }
            //         if (stateCount[4] >= maxCount) {
            //             return NaN;
            //         }

            //         // If we found a finder-pattern-like section, but its size is significantly different than
            //         // the original, assume it's a false positive
            //         var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
            //         if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= originalStateCountTotal) {
            //             return NaN;
            //         }

            //         return this.foundPatternCross(stateCount) ? this.centerFromEnd(stateCount, j) : NaN;
            //     }
            //     this.handlePossibleCenter = function (stateCount, i, j) {
            //         var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
            //         var centerJ = this.centerFromEnd(stateCount, j); //float
            //         var centerI = this.crossCheckVertical(i, Math.floor(centerJ), stateCount[2], stateCountTotal); //float
            //         if (!isNaN(centerI)) {
            //             // Re-cross check
            //             centerJ = this.crossCheckHorizontal(Math.floor(centerJ), Math.floor(centerI), stateCount[2], stateCountTotal);
            //             if (!isNaN(centerJ)) {
            //                 var estimatedModuleSize = stateCountTotal / 7.0;
            //                 var found = false;
            //                 var max = this.possibleCenters.length;
            //                 for (var index = 0; index < max; index++) {
            //                     var center = this.possibleCenters[index];
            //                     // Look for about the same center and module size:
            //                     if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) {
            //                         center.incrementCount();
            //                         found = true;
            //                         break;
            //                     }
            //                 }
            //                 if (!found) {
            //                     var point = new FinderPattern(centerJ, centerI, estimatedModuleSize);
            //                     this.possibleCenters.push(point);
            //                     if (this.resultPointCallback != null) {
            //                         this.resultPointCallback.foundPossibleResultPoint(point);
            //                     }
            //                 }
            //                 return true;
            //             }
            //         }
            //         return false;
            //     }

            //     this.selectBestPatterns = function () {

            //         var startSize = this.possibleCenters.length;
            //         if (startSize < 3) {
            //             // Couldn't find enough finder patterns
            //             throw "Couldn't find enough finder patterns (found " + startSize + ")"
            //         }

            //         // Filter outlier possibilities whose module size is too different
            //         if (startSize > 3) {
            //             // But we can only afford to do so if we have at least 4 possibilities to choose from
            //             var totalModuleSize = 0.0;
            //             var square = 0.0;
            //             for (var i = 0; i < startSize; i++) {
            //                 //totalModuleSize +=  this.possibleCenters[i].EstimatedModuleSize;
            //                 var centerValue = this.possibleCenters[i].EstimatedModuleSize;
            //                 totalModuleSize += centerValue;
            //                 square += (centerValue * centerValue);
            //             }
            //             var average = totalModuleSize / startSize;
            //             this.possibleCenters.sort(function (center1, center2) {
            //                 var dA = Math.abs(center2.EstimatedModuleSize - average);
            //                 var dB = Math.abs(center1.EstimatedModuleSize - average);
            //                 if (dA < dB) {
            //                     return (-1);
            //                 } else if (dA == dB) {
            //                     return 0;
            //                 } else {
            //                     return 1;
            //                 }
            //             });

            //             var stdDev = Math.sqrt(square / startSize - average * average);
            //             var limit = Math.max(0.2 * average, stdDev);
            //             //for (var i = 0; i < this.possibleCenters.length && this.possibleCenters.length > 3; i++)
            //             for (var i = this.possibleCenters.length - 1; i >= 0; i--) {
            //                 var pattern = this.possibleCenters[i];
            //                 //if (Math.abs(pattern.EstimatedModuleSize - average) > 0.2 * average)
            //                 if (Math.abs(pattern.EstimatedModuleSize - average) > limit) {
            //                     //this.possibleCenters.remove(i);
            //                     this.possibleCenters.splice(i, 1);
            //                     //i--;
            //                 }
            //             }
            //         }

            //         if (this.possibleCenters.length > 3) {
            //             // Throw away all but those first size candidate points we found.
            //             this.possibleCenters.sort(function (a, b) {
            //                 if (a.count > b.count) { return -1; }
            //                 if (a.count < b.count) { return 1; }
            //                 return 0;
            //             });
            //         }

            //         return new Array(this.possibleCenters[0], this.possibleCenters[1], this.possibleCenters[2]);
            //     }

            //     this.findRowSkip = function () {
            //         var max = this.possibleCenters.length;
            //         if (max <= 1) {
            //             return 0;
            //         }
            //         var firstConfirmedCenter = null;
            //         for (var i = 0; i < max; i++) {
            //             var center = this.possibleCenters[i];
            //             if (center.Count >= CENTER_QUORUM) {
            //                 if (firstConfirmedCenter == null) {
            //                     firstConfirmedCenter = center;
            //                 }
            //                 else {
            //                     // We have two confirmed centers
            //                     // How far down can we skip before resuming looking for the next
            //                     // pattern? In the worst case, only the difference between the
            //                     // difference in the x / y coordinates of the two centers.
            //                     // This is the case where you find top left last.
            //                     this.hasSkipped = true;
            //                     return Math.floor((Math.abs(firstConfirmedCenter.X - center.X) - Math.abs(firstConfirmedCenter.Y - center.Y)) / 2);
            //                 }
            //             }
            //         }
            //         return 0;
            //     }

            //     this.haveMultiplyConfirmedCenters = function () {
            //         var confirmedCount = 0;
            //         var totalModuleSize = 0.0;
            //         var max = this.possibleCenters.length;
            //         for (var i = 0; i < max; i++) {
            //             var pattern = this.possibleCenters[i];
            //             if (pattern.Count >= CENTER_QUORUM) {
            //                 confirmedCount++;
            //                 totalModuleSize += pattern.EstimatedModuleSize;
            //             }
            //         }
            //         if (confirmedCount < 3) {
            //             return false;
            //         }
            //         // OK, we have at least 3 confirmed centers, but, it's possible that one is a "false positive"
            //         // and that we need to keep looking. We detect this by asking if the estimated module sizes
            //         // vary too much. We arbitrarily say that when the total deviation from average exceeds
            //         // 5% of the total module size estimates, it's too much.
            //         var average = totalModuleSize / max;
            //         var totalDeviation = 0.0;
            //         for (var i = 0; i < max; i++) {
            //             pattern = this.possibleCenters[i];
            //             totalDeviation += Math.abs(pattern.EstimatedModuleSize - average);
            //         }
            //         return totalDeviation <= 0.05 * totalModuleSize;
            //     }

            //     this.findFinderPattern = function (image) {
            //         var tryHarder = false;
            //         this.image = image;
            //         var maxI = qrcode.height;
            //         var maxJ = qrcode.width;
            //         var iSkip = Math.floor((3 * maxI) / (4 * MAX_MODULES));
            //         if (iSkip < MIN_SKIP || tryHarder) {
            //             iSkip = MIN_SKIP;
            //         }

            //         var done = false;
            //         var stateCount = new Array(5);
            //         for (var i = iSkip - 1; i < maxI && !done; i += iSkip) {
            //             // Get a row of black/white values
            //             stateCount[0] = 0;
            //             stateCount[1] = 0;
            //             stateCount[2] = 0;
            //             stateCount[3] = 0;
            //             stateCount[4] = 0;
            //             var currentState = 0;
            //             for (var j = 0; j < maxJ; j++) {
            //                 if (image[j + i * qrcode.width]) {
            //                     // Black pixel
            //                     if ((currentState & 1) == 1) {
            //                         // Counting white pixels
            //                         currentState++;
            //                     }
            //                     stateCount[currentState]++;
            //                 }
            //                 else {
            //                     // White pixel
            //                     if ((currentState & 1) == 0) {
            //                         // Counting black pixels
            //                         if (currentState == 4) {
            //                             // A winner?
            //                             if (this.foundPatternCross(stateCount)) {
            //                                 // Yes
            //                                 var confirmed = this.handlePossibleCenter(stateCount, i, j);
            //                                 if (confirmed) {
            //                                     // Start examining every other line. Checking each line turned out to be too
            //                                     // expensive and didn't improve performance.
            //                                     iSkip = 2;
            //                                     if (this.hasSkipped) {
            //                                         done = this.haveMultiplyConfirmedCenters();
            //                                     }
            //                                     else {
            //                                         var rowSkip = this.findRowSkip();
            //                                         if (rowSkip > stateCount[2]) {
            //                                             // Skip rows between row of lower confirmed center
            //                                             // and top of presumed third confirmed center
            //                                             // but back up a bit to get a full chance of detecting
            //                                             // it, entire width of center of finder pattern

            //                                             // Skip by rowSkip, but back off by stateCount[2] (size of last center
            //                                             // of pattern we saw) to be conservative, and also back off by iSkip which
            //                                             // is about to be re-added
            //                                             i += rowSkip - stateCount[2] - iSkip;
            //                                             j = maxJ - 1;
            //                                         }
            //                                     }
            //                                 }
            //                                 else {
            //                                     // Advance to next black pixel
            //                                     do {
            //                                         j++;
            //                                     }
            //                                     while (j < maxJ && !image[j + i * qrcode.width]);
            //                                     j--; // back up to that last white pixel
            //                                 }
            //                                 // Clear state to start looking again
            //                                 currentState = 0;
            //                                 stateCount[0] = 0;
            //                                 stateCount[1] = 0;
            //                                 stateCount[2] = 0;
            //                                 stateCount[3] = 0;
            //                                 stateCount[4] = 0;
            //                             }
            //                             else {
            //                                 // No, shift counts back by two
            //                                 stateCount[0] = stateCount[2];
            //                                 stateCount[1] = stateCount[3];
            //                                 stateCount[2] = stateCount[4];
            //                                 stateCount[3] = 1;
            //                                 stateCount[4] = 0;
            //                                 currentState = 3;
            //                             }
            //                         }
            //                         else {
            //                             stateCount[++currentState]++;
            //                         }
            //                     }
            //                     else {
            //                         // Counting white pixels
            //                         stateCount[currentState]++;
            //                     }
            //                 }
            //             }
            //             if (this.foundPatternCross(stateCount)) {
            //                 var confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
            //                 if (confirmed) {
            //                     iSkip = stateCount[0];
            //                     if (this.hasSkipped) {
            //                         // Found a third one
            //                         done = this.haveMultiplyConfirmedCenters();
            //                     }
            //                 }
            //             }
            //         }

            //         var patternInfo = this.selectBestPatterns();
            //         qrcode.orderBestPatterns(patternInfo);

            //         return new FinderPatternInfo(patternInfo);
            //     };
            // }


            // //alignpat.js
            // function AlignmentPattern(posX, posY, estimatedModuleSize) {
            //     this.x = posX;
            //     this.y = posY;
            //     this.count = 1;
            //     this.estimatedModuleSize = estimatedModuleSize;

            //     this.__defineGetter__("EstimatedModuleSize", function () {
            //         return this.estimatedModuleSize;
            //     });
            //     this.__defineGetter__("Count", function () {
            //         return this.count;
            //     });
            //     this.__defineGetter__("X", function () {
            //         return Math.floor(this.x);
            //     });
            //     this.__defineGetter__("Y", function () {
            //         return Math.floor(this.y);
            //     });
            //     this.incrementCount = function () {
            //         this.count++;
            //     }
            //     this.aboutEquals = function (moduleSize, i, j) {
            //         if (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize) {
            //             var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize);
            //             return moduleSizeDiff <= 1.0 || moduleSizeDiff / this.estimatedModuleSize <= 1.0;
            //         }
            //         return false;
            //     }

            // }
            // function AlignmentPatternFinder(image, startX, startY, width, height, moduleSize, resultPointCallback) {
            //     this.image = image;
            //     this.possibleCenters = new Array();
            //     this.startX = startX;
            //     this.startY = startY;
            //     this.width = width;
            //     this.height = height;
            //     this.moduleSize = moduleSize;
            //     this.crossCheckStateCount = new Array(0, 0, 0);
            //     this.resultPointCallback = resultPointCallback;

            //     this.centerFromEnd = function (stateCount, end) {
            //         return (end - stateCount[2]) - stateCount[1] / 2.0;
            //     }
            //     this.foundPatternCross = function (stateCount) {
            //         var moduleSize = this.moduleSize;
            //         var maxVariance = moduleSize / 2.0;
            //         for (var i = 0; i < 3; i++) {
            //             if (Math.abs(moduleSize - stateCount[i]) >= maxVariance) {
            //                 return false;
            //             }
            //         }
            //         return true;
            //     }

            //     this.crossCheckVertical = function (startI, centerJ, maxCount, originalStateCountTotal) {
            //         var image = this.image;

            //         var maxI = qrcode.height;
            //         var stateCount = this.crossCheckStateCount;
            //         stateCount[0] = 0;
            //         stateCount[1] = 0;
            //         stateCount[2] = 0;

            //         // Start counting up from center
            //         var i = startI;
            //         while (i >= 0 && image[centerJ + i * qrcode.width] && stateCount[1] <= maxCount) {
            //             stateCount[1]++;
            //             i--;
            //         }
            //         // If already too many modules in this state or ran off the edge:
            //         if (i < 0 || stateCount[1] > maxCount) {
            //             return NaN;
            //         }
            //         while (i >= 0 && !image[centerJ + i * qrcode.width] && stateCount[0] <= maxCount) {
            //             stateCount[0]++;
            //             i--;
            //         }
            //         if (stateCount[0] > maxCount) {
            //             return NaN;
            //         }

            //         // Now also count down from center
            //         i = startI + 1;
            //         while (i < maxI && image[centerJ + i * qrcode.width] && stateCount[1] <= maxCount) {
            //             stateCount[1]++;
            //             i++;
            //         }
            //         if (i == maxI || stateCount[1] > maxCount) {
            //             return NaN;
            //         }
            //         while (i < maxI && !image[centerJ + i * qrcode.width] && stateCount[2] <= maxCount) {
            //             stateCount[2]++;
            //             i++;
            //         }
            //         if (stateCount[2] > maxCount) {
            //             return NaN;
            //         }

            //         var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
            //         if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) {
            //             return NaN;
            //         }

            //         return this.foundPatternCross(stateCount) ? this.centerFromEnd(stateCount, i) : NaN;
            //     }

            //     this.handlePossibleCenter = function (stateCount, i, j) {
            //         var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
            //         var centerJ = this.centerFromEnd(stateCount, j);
            //         var centerI = this.crossCheckVertical(i, Math.floor(centerJ), 2 * stateCount[1], stateCountTotal);
            //         if (!isNaN(centerI)) {
            //             var estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0;
            //             var max = this.possibleCenters.length;
            //             for (var index = 0; index < max; index++) {
            //                 var center = this.possibleCenters[index];
            //                 // Look for about the same center and module size:
            //                 if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) {
            //                     return new AlignmentPattern(centerJ, centerI, estimatedModuleSize);
            //                 }
            //             }
            //             // Hadn't found this before; save it
            //             var point = new AlignmentPattern(centerJ, centerI, estimatedModuleSize);
            //             this.possibleCenters.push(point);
            //             if (this.resultPointCallback != null) {
            //                 this.resultPointCallback.foundPossibleResultPoint(point);
            //             }
            //         }
            //         return null;
            //     }

            //     this.find = function () {
            //         var startX = this.startX;
            //         var height = this.height;
            //         var maxJ = startX + width;
            //         var middleI = startY + (height >> 1);
            //         // We are looking for black/white/black modules in 1:1:1 ratio;
            //         // this tracks the number of black/white/black modules seen so far
            //         var stateCount = new Array(0, 0, 0);
            //         for (var iGen = 0; iGen < height; iGen++) {
            //             // Search from middle outwards
            //             var i = middleI + ((iGen & 0x01) == 0 ? ((iGen + 1) >> 1) : - ((iGen + 1) >> 1));
            //             stateCount[0] = 0;
            //             stateCount[1] = 0;
            //             stateCount[2] = 0;
            //             var j = startX;
            //             // Burn off leading white pixels before anything else; if we start in the middle of
            //             // a white run, it doesn't make sense to count its length, since we don't know if the
            //             // white run continued to the left of the start point
            //             while (j < maxJ && !image[j + qrcode.width * i]) {
            //                 j++;
            //             }
            //             var currentState = 0;
            //             while (j < maxJ) {
            //                 if (image[j + i * qrcode.width]) {
            //                     // Black pixel
            //                     if (currentState == 1) {
            //                         // Counting black pixels
            //                         stateCount[currentState]++;
            //                     }
            //                     else {
            //                         // Counting white pixels
            //                         if (currentState == 2) {
            //                             // A winner?
            //                             if (this.foundPatternCross(stateCount)) {
            //                                 // Yes
            //                                 var confirmed = this.handlePossibleCenter(stateCount, i, j);
            //                                 if (confirmed != null) {
            //                                     return confirmed;
            //                                 }
            //                             }
            //                             stateCount[0] = stateCount[2];
            //                             stateCount[1] = 1;
            //                             stateCount[2] = 0;
            //                             currentState = 1;
            //                         }
            //                         else {
            //                             stateCount[++currentState]++;
            //                         }
            //                     }
            //                 }
            //                 else {
            //                     // White pixel
            //                     if (currentState == 1) {
            //                         // Counting black pixels
            //                         currentState++;
            //                     }
            //                     stateCount[currentState]++;
            //                 }
            //                 j++;
            //             }
            //             if (this.foundPatternCross(stateCount)) {
            //                 var confirmed = this.handlePossibleCenter(stateCount, i, maxJ);
            //                 if (confirmed != null) {
            //                     return confirmed;
            //                 }
            //             }
            //         }

            //         // Hmm, nothing we saw was observed and confirmed twice. If we had
            //         // any guess at all, return it.
            //         if (!(this.possibleCenters.length == 0)) {
            //             return this.possibleCenters[0];
            //         }

            //         throw "Couldn't find enough alignment patterns";
            //     }

            // }


            // //databr.js
            // function QRCodeDataBlockReader(blocks, version, numErrorCorrectionCode) {
            //     this.blockPointer = 0;
            //     this.bitPointer = 7;
            //     this.dataLength = 0;
            //     this.blocks = blocks;
            //     this.numErrorCorrectionCode = numErrorCorrectionCode;
            //     if (version <= 9)
            //         this.dataLengthMode = 0;
            //     else if (version >= 10 && version <= 26)
            //         this.dataLengthMode = 1;
            //     else if (version >= 27 && version <= 40)
            //         this.dataLengthMode = 2;

            //     this.getNextBits = function (numBits) {
            //         var bits = 0;
            //         if (numBits < this.bitPointer + 1) {
            //             // next word fits into current data block
            //             var mask = 0;
            //             for (var i = 0; i < numBits; i++) {
            //                 mask += (1 << i);
            //             }
            //             mask <<= (this.bitPointer - numBits + 1);

            //             bits = (this.blocks[this.blockPointer] & mask) >> (this.bitPointer - numBits + 1);
            //             this.bitPointer -= numBits;
            //             return bits;
            //         }
            //         else if (numBits < this.bitPointer + 1 + 8) {
            //             // next word crosses 2 data blocks
            //             var mask1 = 0;
            //             for (var i = 0; i < this.bitPointer + 1; i++) {
            //                 mask1 += (1 << i);
            //             }
            //             bits = (this.blocks[this.blockPointer] & mask1) << (numBits - (this.bitPointer + 1));
            //             this.blockPointer++;
            //             bits += ((this.blocks[this.blockPointer]) >> (8 - (numBits - (this.bitPointer + 1))));

            //             this.bitPointer = this.bitPointer - numBits % 8;
            //             if (this.bitPointer < 0) {
            //                 this.bitPointer = 8 + this.bitPointer;
            //             }
            //             return bits;
            //         }
            //         else if (numBits < this.bitPointer + 1 + 16) {
            //             // next word crosses 3 data blocks
            //             var mask1 = 0; // mask of first block
            //             var mask3 = 0; // mask of 3rd block
            //             //bitPointer + 1 : number of bits of the 1st block
            //             //8 : number of the 2nd block (note that use already 8bits because next word uses 3 data blocks)
            //             //numBits - (bitPointer + 1 + 8) : number of bits of the 3rd block 
            //             for (var i = 0; i < this.bitPointer + 1; i++) {
            //                 mask1 += (1 << i);
            //             }
            //             var bitsFirstBlock = (this.blocks[this.blockPointer] & mask1) << (numBits - (this.bitPointer + 1));
            //             this.blockPointer++;

            //             var bitsSecondBlock = this.blocks[this.blockPointer] << (numBits - (this.bitPointer + 1 + 8));
            //             this.blockPointer++;

            //             for (var i = 0; i < numBits - (this.bitPointer + 1 + 8); i++) {
            //                 mask3 += (1 << i);
            //             }
            //             mask3 <<= 8 - (numBits - (this.bitPointer + 1 + 8));
            //             var bitsThirdBlock = (this.blocks[this.blockPointer] & mask3) >> (8 - (numBits - (this.bitPointer + 1 + 8)));

            //             bits = bitsFirstBlock + bitsSecondBlock + bitsThirdBlock;
            //             this.bitPointer = this.bitPointer - (numBits - 8) % 8;
            //             if (this.bitPointer < 0) {
            //                 this.bitPointer = 8 + this.bitPointer;
            //             }
            //             return bits;
            //         }
            //         else {
            //             return 0;
            //         }
            //     }
            //     this.NextMode = function () {
            //         if ((this.blockPointer > this.blocks.length - this.numErrorCorrectionCode - 2))
            //             return 0;
            //         else
            //             return this.getNextBits(4);
            //     }
            //     this.getDataLength = function (modeIndicator) {
            //         var index = 0;
            //         while (true) {
            //             if ((modeIndicator >> index) == 1)
            //                 break;
            //             index++;
            //         }

            //         return this.getNextBits(qrcode.sizeOfDataLengthInfo[this.dataLengthMode][index]);
            //     }
            //     this.getRomanAndFigureString = function (dataLength) {
            //         var length = dataLength;
            //         var intData = 0;
            //         var strData = "";
            //         var tableRomanAndFigure = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*', '+', '-', '.', '/', ':');
            //         do {
            //             if (length > 1) {
            //                 intData = this.getNextBits(11);
            //                 var firstLetter = Math.floor(intData / 45);
            //                 var secondLetter = intData % 45;
            //                 strData += tableRomanAndFigure[firstLetter];
            //                 strData += tableRomanAndFigure[secondLetter];
            //                 length -= 2;
            //             }
            //             else if (length == 1) {
            //                 intData = this.getNextBits(6);
            //                 strData += tableRomanAndFigure[intData];
            //                 length -= 1;
            //             }
            //         }
            //         while (length > 0);

            //         return strData;
            //     }
            //     this.getFigureString = function (dataLength) {
            //         var length = dataLength;
            //         var intData = 0;
            //         var strData = "";
            //         do {
            //             if (length >= 3) {
            //                 intData = this.getNextBits(10);
            //                 if (intData < 100)
            //                     strData += "0";
            //                 if (intData < 10)
            //                     strData += "0";
            //                 length -= 3;
            //             }
            //             else if (length == 2) {
            //                 intData = this.getNextBits(7);
            //                 if (intData < 10)
            //                     strData += "0";
            //                 length -= 2;
            //             }
            //             else if (length == 1) {
            //                 intData = this.getNextBits(4);
            //                 length -= 1;
            //             }
            //             strData += intData;
            //         }
            //         while (length > 0);

            //         return strData;
            //     }
            //     this.get8bitByteArray = function (dataLength) {
            //         var length = dataLength;
            //         var intData = 0;
            //         var output = new Array();

            //         do {
            //             intData = this.getNextBits(8);
            //             output.push(intData);
            //             length--;
            //         }
            //         while (length > 0);
            //         return output;
            //     }
            //     this.getKanjiString = function (dataLength) {
            //         var length = dataLength;
            //         var intData = 0;
            //         var unicodeString = "";
            //         do {
            //             intData = this.getNextBits(13);
            //             var lowerByte = intData % 0xC0;
            //             var higherByte = intData / 0xC0;

            //             var tempWord = (higherByte << 8) + lowerByte;
            //             var shiftjisWord = 0;
            //             if (tempWord + 0x8140 <= 0x9FFC) {
            //                 // between 8140 - 9FFC on Shift_JIS character set
            //                 shiftjisWord = tempWord + 0x8140;
            //             }
            //             else {
            //                 // between E040 - EBBF on Shift_JIS character set
            //                 shiftjisWord = tempWord + 0xC140;
            //             }

            //             //var tempByte = new Array(0,0);
            //             //tempByte[0] = (sbyte) (shiftjisWord >> 8);
            //             //tempByte[1] = (sbyte) (shiftjisWord & 0xFF);
            //             //unicodeString += new String(SystemUtils.ToCharArray(SystemUtils.ToByteArray(tempByte)));
            //             unicodeString += String.fromCharCode(shiftjisWord);
            //             length--;
            //         }
            //         while (length > 0);


            //         return unicodeString;
            //     }

            //     this.parseECIValue = function () {
            //         var intData = 0;
            //         var firstByte = this.getNextBits(8);
            //         if ((firstByte & 0x80) == 0) {
            //             intData = firstByte & 0x7F;
            //         }
            //         if ((firstByte & 0xC0) == 0x80) {
            //             // two bytes
            //             var secondByte = this.getNextBits(8);
            //             intData = ((firstByte & 0x3F) << 8) | secondByte;
            //         }
            //         if ((firstByte & 0xE0) == 0xC0) {
            //             // three bytes
            //             var secondThirdBytes = this.getNextBits(8);;
            //             intData = ((firstByte & 0x1F) << 16) | secondThirdBytes;
            //         }
            //         return intData;
            //     }

            //     this.__defineGetter__("DataByte", function () {
            //         var output = new Array();
            //         var MODE_NUMBER = 1;
            //         var MODE_ROMAN_AND_NUMBER = 2;
            //         var MODE_8BIT_BYTE = 4;
            //         var MODE_ECI = 7;
            //         var MODE_KANJI = 8;
            //         do {
            //             var mode = this.NextMode();
            //             //canvas.println("mode: " + mode);
            //             if (mode == 0) {
            //                 if (output.length > 0)
            //                     break;
            //                 else
            //                     throw "Empty data block";
            //             }
            //             if (mode != MODE_NUMBER && mode != MODE_ROMAN_AND_NUMBER && mode != MODE_8BIT_BYTE && mode != MODE_KANJI && mode != MODE_ECI) {
            //                 throw "Invalid mode: " + mode + " in (block:" + this.blockPointer + " bit:" + this.bitPointer + ")";
            //             }

            //             if (mode == MODE_ECI) {
            //                 var temp_sbyteArray3 = this.parseECIValue();
            //                 //output.push(temp_sbyteArray3);
            //             }
            //             else {

            //                 var dataLength = this.getDataLength(mode);
            //                 if (dataLength < 1)
            //                     throw "Invalid data length: " + dataLength;
            //                 switch (mode) {

            //                     case MODE_NUMBER:
            //                         var temp_str = this.getFigureString(dataLength);
            //                         var ta = new Array(temp_str.length);
            //                         for (var j = 0; j < temp_str.length; j++)
            //                             ta[j] = temp_str.charCodeAt(j);
            //                         output.push(ta);
            //                         break;

            //                     case MODE_ROMAN_AND_NUMBER:
            //                         var temp_str = this.getRomanAndFigureString(dataLength);
            //                         var ta = new Array(temp_str.length);
            //                         for (var j = 0; j < temp_str.length; j++)
            //                             ta[j] = temp_str.charCodeAt(j);
            //                         output.push(ta);
            //                         break;

            //                     case MODE_8BIT_BYTE:
            //                         var temp_sbyteArray3 = this.get8bitByteArray(dataLength);
            //                         output.push(temp_sbyteArray3);
            //                         break;

            //                     case MODE_KANJI:
            //                         var temp_str = this.getKanjiString(dataLength);
            //                         output.push(temp_str);
            //                         break;
            //                 }
            //             }
            //         }
            //         while (true);
            //         return output;
            //     });
            // }


            //scripts
            // var gCtx = null;
            // var gCanvas = null;
            // var imageData = null;
            // var ii = 0;
            // var jj = 0;
            // var c = 0;


            // function dragenter(e) {
            //     e.stopPropagation();
            //     e.preventDefault();
            // }
            // function dragover(e) {
            //     e.stopPropagation();
            //     e.preventDefault();
            // }
            // function drop(e) {
            //     e.stopPropagation();
            //     e.preventDefault();
            //     var dt = e.dataTransfer;
            //     var files = dt.files;
            //     handleFiles(files);
            // }
            // function handleFiles(f) {
            //     var o = [];
            //     for (var i = 0; i < f.length; i++) {
            //         var reader = new FileReader();
            //         reader.onload = (function (theFile) {
            //             return function (e) {
            //                 qrcode.decode(e.target.result);
            //             };
            //         })(f[i]);
            //         // Read in the image file as a data URL.
            //         reader.readAsDataURL(f[i]);
            //     }
            // }

            // function read(a) {
            //     alert(a);
            // }

            // function load() {
            //     initCanvas(640, 480);
            //     qrcode.callback = read;
            //     qrcode.decode("meqrthumb.png");
            // }
            // function initCanvas(ww, hh) {
            //     gCanvas = document.getElementById("qr-canvas");
            //     gCanvas.addEventListener("dragenter", dragenter, false);
            //     gCanvas.addEventListener("dragover", dragover, false);
            //     gCanvas.addEventListener("drop", drop, false);
            //     var w = ww;
            //     var h = hh;
            //     gCanvas.style.width = w + "px";
            //     gCanvas.style.height = h + "px";
            //     gCanvas.width = w;
            //     gCanvas.height = h;
            //     gCtx = gCanvas.getContext("2d");
            //     gCtx.clearRect(0, 0, w, h);
            //     imageData = gCtx.getImageData(0, 0, 320, 240);
            // }
            // function passLine(stringPixels) {
            //     //a = (intVal >> 24) & 0xff;
            //     var coll = stringPixels.split("-");

            //     for (var i = 0; i < 320; i++) {
            //         var intVal = parseInt(coll[i]);
            //         r = (intVal >> 16) & 0xff;
            //         g = (intVal >> 8) & 0xff;
            //         b = (intVal) & 0xff;
            //         imageData.data[c + 0] = r;
            //         imageData.data[c + 1] = g;
            //         imageData.data[c + 2] = b;
            //         imageData.data[c + 3] = 255;
            //         c += 4;
            //     }
            //     if (c >= 320 * 240 * 4) {
            //         c = 0;
            //         gCtx.putImageData(imageData, 0, 0);
            //     }
            // }

            // load()